I have a quick question. My brain is fried and I cannot think :(.
Why the following code is not adding tag to MyDivClass:
$("div.MyDivClass").add("<a href='' id='test'><span></span></a>");
$("div.MyDivClass a#test").attr("href","www.test.com");
$("div.MyDivClass a#test span").html("text1");
The add() method only adds the matched elements to the current jQuery object. It does not add new elements to the DOM.
Use append() instead: