1

I am working on html5 app development using Jquery n css. i am creating a image under a div tag as shown below

<div id="FrontRight">
<img id="imgFrontRight" src="../images/car.jpg">
</div>

Now i want this image -imgFrontRight to be draggable with the following attributes

$( "#imgFrontLeft" ). draggable
({ 
    axis: "y" ,
    containment:[0,152,0,290] });

I have achieved this when the image is dynamically created in my jquery javascript file. However i want the same thing to happen when img tag is used to create a image in a html file.

Kindly help with this. Thanku !!

swati
  • 129
  • 1
  • 18
  • How can an img tag be used to create an image in an html file? – Explosion Pills Feb 08 '13 at 07:00
  • would add a image then we add attributes to it as mentioned in the question. Now i am trying to add draggable feature in tag like < img draggable={ axis : "y", containment:[x1,y1,x2,y2] }> This might be wrong. Could you please tell me the right syntax for this. Or any other alternative way to achieve this – swati Feb 08 '13 at 07:12

1 Answers1

0

If you are creating the elements dynamically, then after the dynamic element is added to the dom you need to make draggable by calling jQeury.draggable for it.

$('<img src="" />').appendTo(x).draggable({....});

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531