How to tell which row number is clicked in a table?

前端 未结 6 509
陌清茗
陌清茗 2020-12-01 03:28

I have a table like the following:

6条回答
  •  独厮守ぢ
    2020-12-01 04:05

    $('tr').click(function(){
     alert( $('tr').index(this) );
    });
    

    For first tr, it alerts 0. If you want to alert 1, you can add 1 to index.

提交回复
热议问题