Reputation: 85
I'm able to clone a row using the following jquery code below successfully
$selectedRow.closest("tr").clone(true);
Within this clone tr
, I need to remove the rowspan
attribute from this td
...
<td class="column1" rowspan="1">Testing this column</td>
I tried the following code
$selectedRow.closest("tr").clone(true).find(".column1").removeAttr("rowspan");
The problem with the above code is that it over shows this but it does remove the rowspan
attribute:
<td class="column1">Testing this column</td>
I need it to show everything as in the previous code I wrote above:
$selectedRow.closest("tr").clone(true);
Upvotes: 0
Views: 2582
Reputation: 144689
You can use the end
method which ends the current filtering operation and returns the previous set which is the cloned tr
.
var $clonedRow = $selectedRow.closest("tr")
.clone(true)
// find the `.column1` descendant of the cloned row
.find(".column1")
.removeAttr("rowspan")
// end the current filtering operation
// and return the cloned `tr`
.end();
Note that if the $selectedRow
refers to a tr
element closest
doesn't do anything in this case, as it starts from testing the element itself and then traverses up through its ancestors in the DOM.
Upvotes: 2
Reputation: 1068
var $newClone = $selectedRow.closest("tr").clone(true);
$newClone.find(".column1").removeAttr("rowspan");
Upvotes: 0