Apply Drag to a child element without the parent moving (both have the draggable property)

0

I'm using the HTML5 drag and drop API. It turns out that I have a series of divs to which I apply the drag and drop. And it works well !. Now, each of these divs has other daughters divs to which I also have to apply the drag and drop, but when I take on drag any of the daughters divs comes the complete father. I need that when I apply drag to a son, the father does not apply it. Has anyone already done it? Greetings and thanks in advance!

    
asked by Santiago Trujillo 17.07.2017 в 17:23
source

1 answer

0

In principle you should use the stopPropagation () method to prevent the parent from being dragged too.

element.addEventListener(‘dragstart’, function (evt) {
evt.stopPropagation();
... 
}
    
answered by 17.07.2017 в 17:44