hi im stuck with making a drag and drop function in html5.i tested the code on chrome and when i try to drop it in the area where i made it for dropping the code
it shows a stop sign as arrow. i actually made a bordered section box in which i have some text that i want to be changed when i drop my image in it.
this is my js code:
function doFirst(){
pic = document.getElementById('pic1');
pic.addEventListener("dragstart", startDrag , false);
left = document.getElementById('left1');
left.addEventListener("dragenter", function(e){e.preventDefault();}, false);
left.addEventListener("dragover", function(e){e.preventDefault();} , false);
left.addEventListener("drop", dropped , false);
}
function startDrag(e){
var code = '<img id="pic1" src="D:\tuna\11264353_959682364063264_630153199_n.jpg" />';
e.dataTransfer.setData('hello', code);
}
function dropped(e) {
e.preventDefault();
left.innerHTML = e.dataTransfer.getData('hello');
}
window.addEventListener("load", doFirst , false);