JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<table id="mytable">
    <tr>
        <td>td-1</td>
        <td>td-2</td>
    </tr>
    <tr>
        <td class="exclude">td-3</td>
        <td>td-4</td>
    </tr>
    <tr>
        <td>td-5</td>
        <td>td-6</td>
    </tr>
</table>

CSS

.mark { color: red; }

JavaScript

// Find the correct table...
var table = document.getElementById("mytable"),
    // Find all the td's inside it...
    td = table.getElementsByTagName("td");

// Loop through each td inside the table...
for ( var i=0; i < td.length; i++ ) {
    
    // If td has a class that is anything but .exclude...
    if ( td[i].className !== 'exclude' ) { 
        
        // Add class to all included elements
        td[i].className = "mark";
        
    }
    
}