Cannot drag image inside div

i created a div an want to drag & drop pictures in it… the main problem is, that if it works the image cannot be dragged inside that div.

Code working drag & drop

 $('div[role="textbox"]').on(
    'dragover',
    function (e) {
        e.preventDefault();
        e.stopPropagation();
    }
        );
    $('div[role="textbox"]').on(
        'dragenter',
        function (e) {
            e.preventDefault();
            e.stopPropagation();
        }
    );


    $('div[role="textbox"]').on(
    'drop',
    function (e) {

});

Code drag & drop not working but drag inside div works

//$('div[role="textbox"]').on(
    //'dragover',
    //function (e) {
    //    e.preventDefault();
    //    e.stopPropagation();
    //}
    //    );
    //$('div[role="textbox"]').on(
    //    'dragenter',
    //    function (e) {
    //        e.preventDefault();
    //        e.stopPropagation();
    //    }
    //);


    $('div[role="textbox"]').on(
    'drop',
    function (e) {
//logic
})

Is there a way to combine these two to make both work?

The image is simply inserted as an .


Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.