Wednesday, August 22, 2012

Tips to understand Jquery execution flow

I am new to JQuery. I wrote a small piece of code (fiddle). I was wondering if someone could throw some light on the order of execution of the statements i wrote.


The HTML:



<span>I</span>
<span>Love</span>
<span>JQuery</span>


​The JavaScript:



$(function() {
$(\'<a>Url</a>\').attr(\'href\', \'http://www.jquery.com\').appendTo(\'body\');
$(\'<span>More</span>\').appendTo(\'body\');
$(\'span\'.text());
});​


I was expecting an output of Url I Love JQuery More but the output, as you can see, is I Love JQuery UrlMore. Why is the output in that order? Please help






Rating: 4 out of 5 based on 4 ratings



The post Tips to understand Jquery execution flow appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/tips-to-understand-jquery-execution-flow.html

No comments:

Post a Comment