How can I know what event is happening?

reiver

In HTML5 I have 2 <section>s (2 boxes):

<section  id="leftbox">
  Drag an image here!
</section>

<section id="rightbox">
  <img id="pic" src="images/img1.jpg">
</section>

I want to move the image between the 2 boxes usingJS. I've the following:

leftbox.addEventListener("dragenter", dragenter, false);
leftbox.addEventListener("dragleave", dragleave, false);
leftbox.addEventListener("dragover", function(e){e.preventDefault();}, false);
leftbox.addEventListener("drop", dropped , false);

rightbox.addEventListener("dragenter", dragenter, false);
rightbox.addEventListener("dragleave", dragleave, false);
rightbox.addEventListener("dragover", function(e){e.preventDefault();}, false);
rightbox.addEventListener("drop", dropped , false);

For example, When I'm in function "dragleave", how can I know if the image came from the right or the left box?

ashbuilds

I am not fully understand your Question, But I guess you want to check if your dragged Item is from right or left box !!

Then you should do :

When dragenter then add the data attribute to the element that is dragged from the perticular box,by using something like $(this).parent() and define the attribute of dragged item if the box id is right then right or left for other ! And if you don't want to define the right or left then get offsetLeft.

May this helps you.. If you provide your fiddle then its easy to do so..

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

In javascript, how can i know if an html object property is a property, a method or an event?

From Dev

How can I know the Apple Event Access Groups used by an application?

From Dev

How can I know what version of wif is installed on my server

From Dev

How can I know what Classes inherit from a Class or Interface?

From Dev

What is causing arbitrary JTree Nodes to incorrectly display their names and how can I stop it from happening?

From Dev

How do I know what dependencies I can inject into a controller?

From Dev

My Paint method is running twice and I have no idea why. How can I fix this, and does anyone know why this is happening?

From Dev

In Go, Given an interface{} in which I know what interface it implements, how can I convert to it

From Dev

About NSAttributes, How can I know what attributes there are

From Dev

What is happening when you press escape to exit fullscreen? How can I replicate it with a button?

From Dev

I am trying to integrate pagination in kohana, but don't know what is happening. I get these error " Undefined variable: pager"

From Dev

How can I know what packages can be upgraded to a new version given a composer.json file?

From Dev

I do not know what is happening with my Android Studio, I do not have any component of Google Material

From Dev

How can i remove this deprecation warning in mongoDb and why is it happening?

From Dev

how can I know what's drivers I need to install?

From Dev

Error on the first code I wrote on C++. Don't know what's happening

From Dev

What is happening to my internet connection? I can Ping, query Dns but i cant view webpage?

From Dev

how can I know what T-SQ is executed?

From Dev

What is causing arbitrary JTree Nodes to incorrectly display their names and how can I stop it from happening?

From Dev

How can I troubleshoot what is happening with the console mouse program gpm?

From Dev

My Paint method is running twice and I have no idea why. How can I fix this, and does anyone know why this is happening?

From Dev

How can I execute scripts based on changes that are happening on a specific folder?

From Dev

Why can I (or cannot) mount a mounted device again? What is happening?

From Dev

How meteor know what document "this" refers to in the event

From Dev

How can i know what l am reading with Java Sockets?

From Dev

How can I know an update event on mysql using nodejs with mysql?

From Dev

I don't know what is happening

From Dev

How this if statement works in C. I know what it does but I can't brake it in pieces

From Dev

How can I know what is cached with django cachalot on my server?

Related Related

  1. 1

    In javascript, how can i know if an html object property is a property, a method or an event?

  2. 2

    How can I know the Apple Event Access Groups used by an application?

  3. 3

    How can I know what version of wif is installed on my server

  4. 4

    How can I know what Classes inherit from a Class or Interface?

  5. 5

    What is causing arbitrary JTree Nodes to incorrectly display their names and how can I stop it from happening?

  6. 6

    How do I know what dependencies I can inject into a controller?

  7. 7

    My Paint method is running twice and I have no idea why. How can I fix this, and does anyone know why this is happening?

  8. 8

    In Go, Given an interface{} in which I know what interface it implements, how can I convert to it

  9. 9

    About NSAttributes, How can I know what attributes there are

  10. 10

    What is happening when you press escape to exit fullscreen? How can I replicate it with a button?

  11. 11

    I am trying to integrate pagination in kohana, but don't know what is happening. I get these error " Undefined variable: pager"

  12. 12

    How can I know what packages can be upgraded to a new version given a composer.json file?

  13. 13

    I do not know what is happening with my Android Studio, I do not have any component of Google Material

  14. 14

    How can i remove this deprecation warning in mongoDb and why is it happening?

  15. 15

    how can I know what's drivers I need to install?

  16. 16

    Error on the first code I wrote on C++. Don't know what's happening

  17. 17

    What is happening to my internet connection? I can Ping, query Dns but i cant view webpage?

  18. 18

    how can I know what T-SQ is executed?

  19. 19

    What is causing arbitrary JTree Nodes to incorrectly display their names and how can I stop it from happening?

  20. 20

    How can I troubleshoot what is happening with the console mouse program gpm?

  21. 21

    My Paint method is running twice and I have no idea why. How can I fix this, and does anyone know why this is happening?

  22. 22

    How can I execute scripts based on changes that are happening on a specific folder?

  23. 23

    Why can I (or cannot) mount a mounted device again? What is happening?

  24. 24

    How meteor know what document "this" refers to in the event

  25. 25

    How can i know what l am reading with Java Sockets?

  26. 26

    How can I know an update event on mysql using nodejs with mysql?

  27. 27

    I don't know what is happening

  28. 28

    How this if statement works in C. I know what it does but I can't brake it in pieces

  29. 29

    How can I know what is cached with django cachalot on my server?

HotTag

Archive