Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to drag a DIV if there is a image inside?

 
Lek Kin Wong
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to drag the div which have a image in it:
but i find that if i click on the image, i cannot drag the div, (in FF3.5)
any advice would be appreciated.

and i have a JS something like that...:


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd assume that the image is "on top" of the div (a child), so you're acting on the image, not the div.

I'd search the web for "draggable div" (or something similar) since this problem has obviously been solved thousands of times.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guessing you are getting that save option when you try dragging the inage. You can try canceling the default action:



Eric
 
Lek Kin Wong
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:Guessing you are getting that save option when you try dragging the inage. You can try canceling the default action:



Eric

thank you for your kindly suggestion,
actually i tried this before i make this post, but not working in my situation,
e.target still refer to the img.id, but not the div.id...
 
Lek Kin Wong
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:I'd assume that the image is "on top" of the div (a child), so you're acting on the image, not the div.

I'd search the web for "draggable div" (or something similar) since this problem has obviously been solved thousands of times.


thanks,
im trying img.parentNode... :)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic