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

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

I have a table like the following:

6条回答
  •  有刺的猬
    2020-12-01 04:01

    You can use object.rowIndex property which has an index starting at 0.

    $("table tr").click(function(){
        alert (this.rowIndex);
    });
    

    See a working demo

提交回复
热议问题