Reputation: 11
I want to clone my tr that has a class name cloneme inside a table please help me :(
here is my html code :
<table cellspacing="10" class="tbll" >
<tr>
<td>Choose Sub Heading</td><td><select name="subheading_id" style="min-width:145Px">
<option value="1" Sub heading Me</option>
<option value="2" Sub heading Me 2</option>
</select></td><td> </td>
</tr>
<tr classs="cloneme">
<td>Choose Job Title</td><td><select name="jobtitles_id" style="min-width:145Px"><?php
<option value="a" >A</option>
<option value="b" >B</option>
<option value="c" >C</option>
<option value="none" >None</option>
</select></td>
</tr>
<tr>
<td><div class="addjob" >Add another Job Title</div></td>
</tr>
</table>
Here is my jQuery :
$(".addjob").click(function(){
var $clone = $('table.tbll tr.cloneme').clone();
$('table.tbll').append($clone);
});
thanks in advance..
Upvotes: 0
Views: 287
Reputation: 191749
You have a typo. It's class="cloneme"
not classs="cloneme"
jQuery was not able to find the tr
that you wanted to clone.
You also had some invalid html, but I don't think that was affecting it.
Upvotes: 3
Reputation: 14944
$('table.tbll tr.cloneme').clone().appendTo('table.tbll');
Upvotes: 2