user2016791
user2016791

Reputation: 11

jQuery Cloning tr on a table

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>&nbsp;</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

Answers (2)

Explosion Pills
Explosion Pills

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.

http://jsfiddle.net/6r4Q4/1/

You also had some invalid html, but I don't think that was affecting it.

Upvotes: 3

Bassam Mehanni
Bassam Mehanni

Reputation: 14944

$('table.tbll tr.cloneme').clone().appendTo('table.tbll');

Upvotes: 2

Related Questions