How do I use JQuery to do this? (Loop through the classes)
- by alex
Suppose my code is like this:
<td class="apple">
<div class="worm">
text1
</div>
</td>
<td class="apple">
<div class="worm">
text2
</div>
</td>
<td class="apple">
<div class="worm">
text3
</div>
</td>
How can I loop through everything with "tr class apple", and then grab the text of the div inside with id "worm", and then set each of the .attr() as that text?
Result:
<td class="apple" title="text1">
<div class="worm">
text1
</div>
</td>
<td class="apple" title="text2" >
<div class="worm">
text2
</div>
</td>
<td class="apple" title="text3">
<div class="worm">
text3
</div>
</td>
Thank you