Wednesday, 11 September 2013

append same element into two places

append same element into two places

I have the following html....
<div id="test">
<div>
<img /><img /><img />
</div>
<div>
<img /><img /><img />
</div>
</div>
jquery:
$('#clickto').click(function(){
$('<h1>hi</h1>').appendTo('#test div:nth-child(1)');
$('<h1>hi</h1>').appendTo('#test div:nth-child(2)');
});
The same element I have to append since I appended two times. I think
there is an easy way.
I tried this but appends to only one div:
$('<h1>hi</h1>').appendTo('#test div');

No comments:

Post a Comment