.parent().remove() issue

后端 未结 5 959
慢半拍i
慢半拍i 2021-01-01 18:26

I have a jQuery-based form where you can add extra people to the application. I\'m cloning the first fieldset and adding it onto the end up to a max of 3 additional people.

5条回答
  •  难免孤独
    2021-01-01 19:01

    The 'live' function call has been deprecated and no longer works. You can find instructions for how to rewrite functions using the replacement 'on()' method here and more info about the deprecation:

    http://api.jquery.com/live/

    To handle all current and newly created elements, you must now use:

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

    jQuery runs on the document object, not the element and there is an additional parameter to specify which elements to watch and add event listeners to.

提交回复
热议问题