Home How do I add different classes to <td> in Javascript
Reply: 0

How do I add different classes to <td> in Javascript

user983
1#
user983 Published in April 26, 2018, 1:41 pm

Hey I have two td elements in a table.

I want the have separate style classes for them. How do I do this?

This is my code:

table += "<tr>";
  for(var i = 0; i < data.list.length; i++){
    table += "<td>" + "<table>" + "<td>" + value1 "</td>" + "<td>" + value2 + "</td>" + "</table>";
  }
table += "</tr>";

I have tried to simply add class in td element but that does not work.

Any ideas? I use Javascript to create the table.

So this does not work:

table += "<tr>";
  for(var i = 0; i < data.list.length; i++){
    table += "<td>" + "<table>" + "<td class="one">" + value1 "</td>" + "<td class="two">" + value2 + "</td>" + "</table>";
  }
table += "</tr>";
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.850474 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO