[jQuery] appendTo Weirdness
I'm seeing some strange behavior with appendTo. Specifically, if I
append an object to two items, it only appends the object to the last
item. If I append it to three items, all are appended correctly.
Here's some code to show this off:
SCRIPT
$(function() {
var commandLink = $("<span>[Command Link]</span>");
$("#container1").append(commandLink);
$(".container").append(commandLink);
});
HTML
<div id='container1' style='background-color: Yellow; padding:
10px;'></div>
<div id='container2' class='container' style='background-color: Pink;
padding: 10px;'></div>
<div id='container3' class='container' style='background-color: Lime;
padding: 10px;'></div>
If #container3 exists, all three get the new span added to them. If
#container3 is commented out, only #container2 gets the span added.
Can anyone else reproduce and/or offer a suggestion?
Thanks