jQuery: how do I check if an element is the last sibling?

前端 未结 5 1033
梦谈多话
梦谈多话 2020-12-05 01:29

How do I check if an element is the last sibling?

For the last cell in a row I want to perform a different action.

This doesn\'t work:

$(\'td         


        
5条回答
  •  [愿得一人]
    2020-12-05 02:19

    you can code this way.

    var $this = $(this);
    if($this.index()==$this.siblings().size()-1)
    {
       alert("It's the last.");
    }
    

提交回复
热议问题