Hi I am new to jQuery and trying work on a proof of concept. I have posted the example code here and my requirement is as follows.
I have 2 droppables dog/sheep and I want to drop them on the shirt.
I drop the sheep/dog on the shirt but as soon as drop it goes to the down-left position of the div.
I tried doing $('[id$="apparel"]').append(dropElem);
instead of $(this).append(dropElem);
Can some one please help me in this?
Appreciate your time.
thanks John
this is my javascript
$(".items").draggable({helper: 'clone'});
$(".droparea").droppable({
accept: ".items",
hoverClass: 'dropareahover',
tolerance: 'touch',
drop: function(ev, ui) {
var dropElemId = ui.draggable.attr("id");
var dropElem = ui.draggable.html();
$(this).append(dropElem);
alert("drop done");
}
});
And the HTML
<div class="wrap">
<div class="sourcearea">
<span class="items" id="itemsheep">
<img src="sheep.jpg" width="100">
</span>
<span class="items" id="itemdog">
<img src="dog.jpg" width="100">
</span>
</div>
<div class ="droparea">
<img src="RedShirt.jpg" width="300" height="300" id="apparel">
</div>
</div>