Answers for "how to get selected row index of table in javascript"

0

how to get selected row index of table in javascript

<html>
<head>
<title>Row indexes</title>
<script type="text/javascript">
onload = function() {
    if (!document.getElementsByTagName || !document.createTextNode) return;
    var rows = document.getElementById('my_table').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
    for (i = 0; i < rows.length; i++) {
        rows[i].onclick = function() {
            alert(this.rowIndex + 1);
        }
    }
}
</script>
</head>
<body>
<table id="my_table">
<tbody>
    <tr><td>first row</td></tr>
    <tr><td>second row</td></tr>
</tbody>
</table>
</body>
</html>
Posted by: Guest on May-01-2020
0

how to get selected row index of table in javascript

hii
hhhh
Posted by: Guest on May-05-2021

Code answers related to "how to get selected row index of table in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language