html - How to know index of a <tr> inside a <table> with jQuery? -
I am implementing something like this (in particular, the effect occurs when the row is clicked)
How do I know what is the indicator of the row inside the table?
If you define click handler directly on the tr
elements, you You can use the index
method in this way:
$ ('# tableId tr'). (Function () {var rowIndex = $ ('# tableId tr'). Index (this); // index #tableId relative to lines;);
If the click event is not directly bound to the tr
element (if you are using an anchor, a button, etc.), then you The nearest tr
:
$ (selector) to get the correct index should be found. Click (function () {var rowIndex = $ ('# tableId tr'). ($ (This). Close ('tr'); return false;});
Try an example.
Comments
Post a Comment