Iterating changes using jQuery?
Posted
by HipHop-opatamus
on Stack Overflow
See other posts from Stack Overflow
or by HipHop-opatamus
Published on 2010-04-19T21:57:32Z
Indexed on
2010/04/19
22:03 UTC
Read the original article
Hit count: 369
In the HTML below, I would like to copy the "submittedby" beside "message", within the H2 tag:
<div class="comment">
<H2 class="threadtitle">Message 1</h2>
<span class="submittedby">James</a>
</div>
<div class="comment">
<H2 class="threadtitle">Message 2</h2>
<span class="submittedby">Bill</a>
</div>
<div class="comment">
<H2 class="threadtitle">Message 3</h2>
<div class="submittedby">Phil</a>
</div>
My current jQuery code is as follows:
$(document).ready(function() {
$('.submittedby').copy().appendTo('.threadtitle');
});
The problem is this copies EVERY "submittedby" to EVERY "threadtitle". How do I code it so it only copies the "submittedby" from within the same "comment" div? Thanks!
© Stack Overflow or respective owner