简体   繁体   中英

Fire an event when one element is over another

For an example, lets say I drag an element over another element. Is there a way to fire an event when they touch each other?

I'm trying to do this in javascript or jquery.

As you didn't post any code, I could just give you an idea on how to approach this issue:

You probably could use the .offset method of jQuery ( https://api.jquery.com/offset/ ). You can listen to the drag event and then check the offset of the draggable element against the target element.

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