How to check if the element is not the first-child?

前端 未结 10 1940
北荒
北荒 2021-01-01 10:26

How do you know if the current element is not the first-child?

It should work with $(this), for example:

$(\"li\").click(function(e) {
          


        
10条回答
  •  执念已碎
    2021-01-01 11:31

    Keep it simple, use the DOM

    
    $("li").click(function(e) {
    
        if (this.previousSibling != null)
        {
            /* do something */
        }
    
    });
    

提交回复
热议问题