File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to drag a DIV if there is a image inside? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to drag a DIV if there is a image inside?" Watch "How to drag a DIV if there is a image inside?" New topic
Author

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

Lek Kin Wong
Ranch Hand

Joined: Feb 23, 2010
Posts: 30
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Feb 23, 2010
Posts: 30
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

Joined: Feb 23, 2010
Posts: 30
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... :)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to drag a DIV if there is a image inside?