Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/myscript/public_html/codes-snippets/config.php on line 6
Get Table Row Column Index - Jquery

Get Table Row Column Index - Jquery

How to get table row and column index using jquery?

Snippet Code


  
Rate this page :
  [ 0 votes]

Use the below jQuery code to get the index of clicked table row and column.

<script type='text/javascript'> $(function() { $('td').click(function(){ var column = $(this).parent().children().index($(this)); var rows = $(this).parent().parent().children().index($(this).parent()); alert('Row Index: ' rows ', Column Index: ' column); }); }); </script> <p align='center'><b>Get Table Row Column Index</b></p> <table border="1" align='center'> <tr><th>S.No</th><th>Product_name</th><th>Product_id</th></tr> <tr><td>1</td><td>Nestle</td><td>105</td></tr> <tr><td>2</td><td>Nescafe</td><td>07</td></tr> <tr><td>3</td><td>Boost</td><td>125</td></tr> </table>

Tags


Ask Questions

Ask Question