Server Name

Refresh cell cell using jquery

ok, so I have a table with the following:

<table id="servertable">
        <tr>
        <th scope="col">Server Name</th><th scope="col">Location</th><th scope="col">Status</th>
        </tr><tr><td>servername1</td><td>pathtoserver1</td><td>Unknown</td></tr>
        <tr><td>servername2</td><td>pathtoserver2</td><td>Unknown</td></tr>
        <tr><td>servername3</td><td>pathtoserver3</td><td>offline</td>
        </tr>
    </table>

      

and trying to update the server status (using jquery) based on "pathtoserver", say a javascript function gets, "pathtoserver2" and "online". I would like to place the server in a table and replace the value with "Unknown" or whatever it might be with "online".

I've tried something like this: $ ('# stvertable td'). find ("#" + server); - find the server, but it's looking for an id, so I'm not sure if I need to assign an id to the content of the "pathtoserver" values, or if there is a way to use the ".each (function (..)" construct to host it and therefore update her.

so i used this: $('#servertable td:contains(' + server + ')')

and it almost works, except I need to find an exact match, so I change it to:

$('#servertable td:eq(' + server + ')')

      

However, now it only finds the first one (I think), how do I find all the exact matches?

0


a source to share


1 answer


This should find a td with the server name, assuming the variable is named "server":

$('#servertable td:contains(' + server + ')')

      



To get the next td just add .next()

to this.

0


a source







All Articles