I'm trying to create a div
every time I drop an image on top of another div
, but the following is occurring:
- At once: create 1 Div;
- On the 2nd time: create 2 Div;
- 3 times: create 3 Div;
Is there an internal counter in events ondragstart
and ondrop
?
<img ondragstart="dragStart(event)" class="icon" src="imagens/01.jpg" />
function dragStart(event) {
elem = event.target.getAttribute('id');
}
function drop(event) {
$('<div class="img"></div>').appendTo('#centro');
$('#'+elem).appendTo('.midia');
}