html - Remove individual td's during deleting rows using jQuery -


In my web application, I had to add dynamic / delete rows from my html table using jQuery.

  $ (function () (/)    

* Existing table * / // one line $ Add new row to HTML template of "(contact #"). Each (function () {$ ("button.addCommentRow", this) .live ('click', function) {var curr_row = $ (this) Html = '& lt; tr & gt; & lt; td & gt; gt; & lt; td & gt; & lt; / td & gt; & lt; at the closest (' tr '); ; TD & gt; gt; & lt; TD & gt; '+ col_ninth +' & L T; / td> gt; td & gt; & gt; button type = "button" class = "addCommentRow" & gt; + & lt; / button & gt; & gt; button type = "button" square = "DeleteCommentRow" & gt; - & lt; / button & gt; & lt; / td & gt; & lt; / tr & gt; Var newre = $ (Html) .insertAfter (curr_row); // last new Add after 'row.find' ('.com.conduitRow, .deletecommentRow'). Button (); ... NewRow.find ('. DeleteCommentRow') Click on the button () (function {} {newRow.find ("TD: nth child (9)") delete (); newRow.find ("TD: nth (10) "). Remove ();}); }); }); }); So, on the removal, I wanted to remove the 9th and 10th TD elements from my line.

The above code (excluding part) does not seem to be highly appreciated any thoughts / suggestions to work.

Thanks,
Chitish

:

  & lt; Table border = 2> & Lt; TR & gt; & Lt; TD & gt; JQuery & lt; / TD & gt; & Lt; TD & gt; Mootools & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Dojo & lt; / TD & gt; & Lt; TD & gt; Fuel & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Raphael & lt; / TD & gt; & Lt; TD & gt; Rico & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; SproutCore & lt; / TD & gt; & Lt; Td> The lively kernel & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt;  

JavaScript :

  $ (function () {$ ('tr'). Find ('td'). Parent () // Travising for 'tr' element .append ('& lt; td & gt; & lt; input type = "button" value = "delete" class = "del" Gt; & lt; Input Type = "Button" value = "Delete Row" category = "Delo" /> gt; & lt; / td & gt; '); $ ('. Del ') Click (function {$ (This) .Parent (). (); // Delete TD element}} $ ('.'). Click (function () {$ (this) .Parent () .Parent (). Remove (); // delete the line (tr) element});});  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -