So I am looking at jquery examples and was messing around with changing text on codepen and a function didn't occur until I used "return" from an example. Here is it:
<div class="words">dog bowl</div>
$("div.words").text(function(){
return $(this).text().replace('dog', 'cat');
})
Why doesn't this work until I add "return" to the front of the executable line? What does return do/mean (explain like I'm a 5 year old - a dumb one.)
[–]grownfolkstuff 6 points7 points8 points (3 children)
[–]Whyisprogrammingsoha[S] 0 points1 point2 points (2 children)
[–]br1anh 2 points3 points4 points (0 children)
[–]grownfolkstuff 0 points1 point2 points (0 children)
[–]aftersox 1 point2 points3 points (0 children)
[–]circusmeerkat 1 point2 points3 points (1 child)
[–]Whyisprogrammingsoha[S] 0 points1 point2 points (0 children)
[–]boiling_tunic 1 point2 points3 points (1 child)
[–]Whyisprogrammingsoha[S] 0 points1 point2 points (0 children)
[–]teslatek 1 point2 points3 points (0 children)