jquery: event.stopImmediatePropagation() vs return false

后端 未结 5 2183
你的背包
你的背包 2020-12-02 05:35

Is there any difference between calling event.stopImmediatePropagation() and return false inside an event handler ?

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 05:52

    Yes. event.stopImmediatePropagation() won't let any other handlers for that event be called, regardless of where they are bound. Return false only stops handlers bound to other elements (ie not the same element as the event handler dealing with the stopImmediatePropagation() call) from receiving the event.

提交回复
热议问题