How to delete parent element using jQuery

后端 未结 7 1775
深忆病人
深忆病人 2020-11-28 05:01

I have some list item tags in my jsp. Each list item has some elements inside, including a link (\"a\" tag) called delete. All that I want is to delete the entire list item

7条回答
  •  长情又很酷
    2020-11-28 05:10

    Delete parent:

    $(document).on("click", ".remove", function() {
           $(this).parent().remove(); 
    });
    

    Delete all parents:

    $(document).on("click", ".remove", function() { 
           $(this).parents().remove();
    });
    

提交回复
热议问题