简体   繁体   中英

call to event listeners of a certain element instead of the one in the event listeners of the body

I have a eventListeners for all the body for touchevents but inside a certain element that is inside the body I want to make different thing for those touchevents. The problem is that even if I add eventListeners to that element when I touch the element it calls to the eventListener that is set for the body. How can I make to remove the body eventListener but only in the element that I want? or to call to the eventListener that I put in the element instead of call to the eventListener that is in the body?

you need to use event.stopPropagation().

Here you can read more about it: http://www.w3schools.com/jquery/event_stoppropagation.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM