jquery - Insert Row(child) in table using JavaScript -
i have table containing 4 main rows , 1 (expand or collapse) button.on click of (expand or collapse) button want insert 1 more row in middle of rows(which result in total 8 rows) iterating table rows.how using javascript?see image below.any suggestion.

this code have return on click of expand or collapse button,
jquery('#btnid').click(function() { var = this; $("#example tbody tr").each(function(i) { //what code need add here }); });
due fact, haven't provided code example, can suggest 1 way achieve this.
you can determine row above row you'll want insert id on tr or css selector :nth-of-type(4) example.
after that, can use row jquery element (example: $("tr#yourrow")) , append row after using append().
example: $("tr#yourrow").append("<tr>... row definition ...</tr>")
based on updated question:
jquery('#btnid').click(function() { var = this; $("#example tbody tr").each(function(i, object) { $(object).after("<tr>... row definition ...</tr>") }); }); the row definition should done yourself. don't know logic behind iteration in case. think you'll it. :)
Comments
Post a Comment