How to find the closest event element

后端 未结 2 744
终归单人心
终归单人心 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:17

    As suggested by Rory McCrossan; your first hideBox present directly in

    tag which is invalid; and 2nd hideBox's which is also invalid. So I am using below HTML which is somewhat different from yours but I believe you want that only

    HTML:

    JQuery code:

    $(".hideBox-tab").click(function(){
        $(this).closest("tr").find(".hideBox").toggle();
        return false;
    }); 
    

    提交回复
    热议问题
    present outside of
    show div
    show div