I am getting
this.parentNode = '<tr><td>One</td>' +
'<td>Two</td>' +
'<td>Three</td>' +
'</tr>';
Now, I need to add a class to the <tr>.
In a normal scenario, I can just do $('#tableId tr').addClass('classname');
However, in this case I have the html inside this.parentNode. How can I add the classname to the <tr> here?
You can do 2 things:
This,
this.parentNode = '<tr class="className"><td>One</td>' +
'<td>Two</td>' +
'<td>Three</td>' +
'</tr>';
Or this,
Define the this.parentNode just like how you did, and then do this :
$(this.parentNode).addClass("className")
This adds the class to the tr tag in the parentNode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With