I'm new to jQuery, and I'm looking through a tutorial that covers DOM changing.
Here's an example from that tutorial.
HTML part:
<h1>My Awesome Post</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</p>
Script
(function() {
$('p').eq(0).after(function() {
return $(this).prev();
});
})();
I don't get why do I need to use the function here if all it does is returning a value? Why the following statement doesn't work?
$('p').eq(0).after( $(this).prev());