jquery remove parent not working on dynamically created divs

后端 未结 3 1712
傲寒
傲寒 2021-02-14 12:06

im trying to use jquery in order to make a button remove its parent div.

my markup:

3条回答
  •  迷失自我
    2021-02-14 12:58

    Do not use a live handler -- it has been deprecated in jQuery 1.7 and removed in jQuery 1.9 -- a breaking change for a great many people.

    Instead, use the on handler, which is the recommended way now:

    $(document).on('click', '.button_remove_web_store', function() {
        $(this).parents("div:first").remove();
    });
    

提交回复
热议问题