How to find the closest event element

后端 未结 2 776
终归单人心
终归单人心 2021-01-29 08:56

I\'m using jQuery. I want to find the closest class .hidebox to the element that created the event. I tried to use parent, find and

2条回答
  •  攒了一身酷
    2021-01-29 09:40

    Despite of your html validity you can try do it like this:

    $(".hideBox-tab").click(function(){
        $(this)
            .closest("tr")
            .next("tr")
        		.find(".hideBox")
            .toggle();
        return false;
    }); 
    .hideBox {
      display:none;
    }
    
    
    show div
    aaa
    show div
    bbb

提交回复
热议问题