samedi 28 octobre 2017

javascript - select nodes and all their child nodes inside tbody

I want to select all elements inside < tbody > and all their sub-elements so i can change a class using javascript.

For example, i want to change the class cl1 into cl2 in the following example

<table>
    <thead>
         ....
    </thead>
    <tbody>
        <tr class="cl1 other-class">
            <td>Some value</td>
            <td class="cl1 other-class">Some value</td>
            <td>Some value</td>
        </tr>
        <tr class="cl1 other-class">
            <td class="cl1 other-class">Some value</td>
            <td>Some value</td>
            <td>
                <a class="cl1 link" href="#">Some link</a>
            </td>
        </tr>
    </tbody>

I want to use javascript for this, no jQuery




Aucun commentaire:

Enregistrer un commentaire