In jQuery, the use of JavaScript is simplified. jQuery has its own appendChild equivalent which is used to append content to the inside of matched element.
If you use jQuery to select an element, and to append content, the syntax is like below:
$("p").append("<strong>Arctic Monkeys</strong>");
As you can see, this is very easy to use and comes in relly handy when perfoming content population task using JavaScript.
Hope this helps!











































#1 by sonny cabali on June 24, 2009 - 1:36 am
This is not working in IE 7
#2 by Blurp Blub on February 11, 2010 - 11:43 pm
Unfortunately, that’s an innerHTML equivalent, not an appendChild equivalent.
#3 by Blurp Blub on February 11, 2010 - 11:49 pm
I’ll backpedal slightly and say that append() *can* function as an appendChild() equivalent, but your example doesn’t show that. A better example would be:
var strong = document.createElement(“strong”);
strong.appendChild(document.createTextNode(“Arctic Monkeys”));
$(“p”).append(strong);
One might ask why you’d ever use append() this way, rather than your way. Generally I agree, but perhaps you have a piece of third-party code that returns DOM objects, but you prefer jQuery methods. Enter this usage to glue them together.