Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  30] [ 6]  / answers: 1 / hits: 20654  / 11 Years ago, fri, august 23, 2013, 12:00:00

This code should make an element disappear from a list when it is dropped on another element (called cookiemonster)



addEvent(cookiemonster, 'drop', function (e) {
if (e.stopPropagation) e.stopPropagation();

var el = document.getElementById(e.dataTransfer.getData('text'));
el.parentNode.removeChild(el);
return false;
});

More From » javascript

 Answers
38

create an auxiliar variable like this



addEvent(cookiemonster, 'drop', function (e) {
if (e.stopPropagation) e.stopPropagation();

var el = document.getElementById(e.dataTransfer.getData('text'));
var aux = el.parentNode;
aux.removeChild(el);
return false;
});

[#76172] Friday, August 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaileya

Total Points: 168
Total Questions: 95
Total Answers: 72

Location: Antigua and Barbuda
Member since Sat, Apr 24, 2021
3 Years ago
;