jquery stopPropagation problem with live method

前端 未结 3 1297
灰色年华
灰色年华 2021-01-13 10:57

Jquery stopPropagation method dosen\'t work with live method. Below the code is works fine with click instead of live method. Any help greatly appreciated.

Code:<

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 11:38

    That is because .live() relies on event propagation.

    The event is not actually placed on the element, but rather on the root node. The event then bubbles up to that node, checks the selector to see if it has a match, and fires if so.

    Because the event isn't fired until it is already at the top of the hierarchy, there's no propagation left to stop.

提交回复
热议问题