0

I have roughly 200 tables on my site. All of them are set up the same way, so making a change on one of them, changes all of them.

It would be extremely time consuming to go through each table and give it a class name.

Is it possible to apply css, depending on the text within the table?

For example, my table would look like this:

<tr>
<th colspan="2">Table 1</th>
</tr>

Then what I want is: If th has text "Table 1" then apply this css:

th {
 background-color: #b2591a;
}
Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
GenesisBits
  • 364
  • 2
  • 23
  • 1
    I don't think that you can do it using CSS, but you can using javascript http://stackoverflow.com/questions/1520429/is-there-a-css-selector-for-elements-containing-certain-text – Amr Elgarhy Oct 21 '16 at 10:03
  • Yep javascript is your friend here. Remember it will break if someone has js turned off in their browser. I would suggest if it's only one table to add a class to that table then you can use css. – Nathaniel Flick Oct 21 '16 at 10:04
  • you can do it with also jquery: $('td:contains("Table 1")') – chirag Oct 21 '16 at 10:05

0 Answers0