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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.