Can someone explain why the following snippet does not add to both #a and #b?
HTML:
Try clone. This, as the name implies, will copy the $foo element and not move, like append will do.
$(function(){
var $foo = $("HI ");
$("#a").append($foo.clone());
$("#b").append($foo.clone());
});
But, why not just use this?
$("#a,#b").append($foo);
This will also work :)
Here's a demo for both these situations : http://jsfiddle.net/hungerpain/sCvs7/3/