Jquery appendTo a specific table ID not working -
i have table 1 <tr> , 6 <td>'s inside. using bit of code remove tr , placing new tr tag after last td.
before
<table id="datatable" class="datatable_class"> <tbody> <tr> <td id="td1">title 1</td> <td id="td2">contents 1 need go new tr</td> <td id="td3">title 2</td> <td id="td4">contents 2 need go new tr</td> <td id="td5">title 3</td> <td id="td6">contents 3 need go new tr</td> </tr> </tbody> after
<table id="datatable" class="datatable_class"> <tbody> <td id="td1">title 1</td> <td id="td2">contents 1 need go new tr</td> <td id="td3">title 2</td> <td id="td4">contents 2 need go new tr</td> <td id="td5">title 3</td> <td id="td6">contents 3 need go new tr</td> <tr></tr> </tbody> what trying achieve .appendto() odd td's newly created tr. works fine problem have table in <body> , when start moving td's around, move td's other table new tr.
i tried using filter no luck
$("#datatable > tbody > td.odd").appendto('#fix_name').css( "background-color", "red" );
here's how can move desired table cells without affecting second table. , more precise can use table id instead of table:first - #datatable td:odd more precise selector.
$('#simple_button').click(function () { $( '<tr id="fix_name"/>' ).insertafter( $("#td6").closest('tr') ); $( 'table:first td:odd' ).appendto('#fix_name').css( "background-color", "red" ); });
Comments
Post a Comment