javascript - Drop Files Into Dynamically Generated Content -
i'm trying change src
of dynamically generated placeholder image dropping image on it, can't data dropped image. i've tried couple ways , neither works.
method 1:
console.log(e.datatransfer);
returns undefined
method 2:
console.log(e.originalevent.datatransfer.files.length);
returns no files. here's working sample of probem: jsfiddle. missing?
update: @marcel points out, drop event receives data when users drag computer, doesn't data images loaded in browser. end goal have users drag images browser tab or window , update placeholder url dropped image's url.
if else looking achieve same functionality, able code bits below.
var droppedimage = e.originalevent.datatransfer.getdata('text/html'); var imageurl = $(droppedimage).attr('src');
it works images on same page & images dragged browser window/tab.
Comments
Post a Comment