How to remove $(document).on click event?

前端 未结 7 2043
孤独总比滥情好
孤独总比滥情好 2021-01-06 08:13

Here is the code to add event

   $(document).on({
      click: function() {
        $(this).hide();
        $(\'#form_name\').removeClass(\'hide\');
                 


        
7条回答
  •  感情败类
    2021-01-06 09:06

    An event handler is bound to an element. You can unbind an event handler from the element it is attached to, but you can't unbind it from a descendant element since that isn't where it is listening.

    You can either:

    1. Examine the target property of the event object (the first argument to your event handler function) to see what element was clicked on and then return before doing anything.
    2. Bind a new event handler to the elements you want stop the event from triggering from and prevent the event from continuing up the DOM.

提交回复
热议问题