I am trying to add a row to existing table by using clone() method. It is working fine and I also want to change CSS class name for all div elements under each td from the original row. Basically I want to make some td elements as editable. I have tried this by adding “row.find(“td div”)…” as you see in the code, but this code has no effect at all. Any suggestions?
$("#create_blank_scenario").click(function(){
var row = $('#sortable_offer_table tbody tr:first').clone(true);
row.find("td div").addClass("editable");
row.insertBefore('#sortable_offer_table tbody tr:first');
});
Perhaps there is an issue with your markup, as your code seems to be working just fine for me. Here’s a demo of it working: http://jsfiddle.net/gkEbp/
I created some dummy html:
Added a CSS rule to highlight
.editableand ran your code against it. As you can see, it works.