I am testing jQuery's .append()
vs .appendTo()
methods using following code:
$('div/>', {
id : id,
text : $(this).text()
}).appendTo('div[type|="item"]#'+id);
$('div[type|="item"]#'+id).append($(this).text());
Note that the selectors are identical in .appendTo()
and .append()
, yet the latter works (within the same page), while the former does not. Why?
How do I get .appendTo()
to work with this type of (complex) selector? Do the two methods interpolate differently? Is there some syntax I'm missing?
I don't want to clutter the post with impertinent code: suffice it to say that elements referenced by selectors exist, as is evidenced by the .append()
method producing desired result. Let me know if more info is needed.
Thanks!