Tutorial :In jQuery, how does prepend() work on a children() function?


I am a little confused on how prepend acts towards a children function.


where would this.area appear?


It adds this.area (or a clone) as the first child of every matching child of image.canvas. Matching children are those with the image-pinpoint-view class. A DOM node can only be in one place, but jQuery will clone the element so there's one for each desired parent.


Prepend puts the specified content at the beginning of the element.

<div id="content">     <div id="a">data</div>  </div>    $('#content').prepend('<div id="b">prepended data</div>');  

would result in

<div id="content">     <div id="b">prepended data</div>     <div id="a">data</div>  </div>    $('#content').prepend( $('#a') );  

would result in

<div id="content">         <div id="a">data</div>         <div id="b">prepended data</div>      </div>  


Every jQuery object is an array. Every jQuery method is applied to all elements. If you write:


...the style will be applied to all elements.

Similarly, in your case, the element (this.area) will be cloned and one clone will be inserted before each children.

See it in action.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »