[Solved] Get td value from specific tr (with mouse hover)


Pure JavaScript Solution

There are a bunch of jQuery answers but no jQuery tag so I’m offering a pure JavaScript solution for you. Installing a large library for this simple task seems pointless.

You can assign the row to a Javascript variable like this, and look for mouseover.

To get the first TD’s content, you can use a function like this:

function getFirstTdContent(row) {
    elem = row.children[0];
    alert(elem.textContent); // Do whatever you want to do with the content here
}

To call it, declare your row like this:

<tr onmouseover="getFirstTdContent(this);">
    <td>This should be returned</td>
    <td>This should not be returned</td>
</tr>

solved Get td value from specific tr (with mouse hover)