Reputation: 443
I am using jquery to clone the row from SOURCE table & append it in TARGET table. After clone & before APPEND I want to remove class "my_green" & also replace class "search_row" with another class "final_row".
<tr>
<td class='text-center' id='111'>
<span class='my_green search_row' aria-hidden='true' >
</td>
<td>KoaMsRohEdDfg2C</td>
<td class='text-nowrap' >C-12-5-16</td>
<td></td>
<td>Silver</td>
</tr>
$('document').ready(function(){
$('.source_table').on('click', function (e) {
var row = $(this).closest('tr').clone();
$(row).addClass("remove");
// Here I want to remove "my_green" class from clone
// and also replace "search_row" class with another class "final_row".
$('.target_table').append(row);
});
$(document).on("click", ".remove", function() {
$(this).closest("tr").remove();
});
});
Upvotes: 2
Views: 536
Reputation: 5745
You can just find your class identifier, remove your class and toggle between your 2 class. Please try:
row.addClass("remove").find(".search_row").removeClass("my_green").toggleClass("final_row search_row");
Upvotes: 2