javascript - How to append data transfer content at specific location on HTML5 drop event -


i'm developing html5 drag-and-drop on body tag. images can dropped @ place. when drop on tag (div's, paragraphs, etc) works correctly. (i need prepend @ these cases). when drop on body, placed before other elements. how can append data @ specific location (event.clientx , event.clienty) when it's on body tag?

document.elementfrompoint() give me body tag.

content id 'body' tag.

$('#content')     .bind('drop', function(event){         event.preventdefault();         var data=event.originalevent.datatransfer.getdata("text");                   $(event.originalevent.target).prepend(data);     })  ; 

just check if target of event body , give target in case:

$('#content').bind('drop', function(event){     event.preventdefault();     var data = event.originalevent.datatransfer.getdata("text");      if (event.originalevent.target.id == 'content')         $('#divforotherimages').append(data);     else         $(event.originalevent.target).prepend(data); }); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -