drag and drop not working in firefox

前端 未结 2 781
不思量自难忘°
不思量自难忘° 2020-12-20 14:00

I have implemented drag and drop functionality in JQuery and html5 , its working great in chrome but stuck in Firefox following is my code where i am alerting id of dropped

相关标签:
2条回答
  • 2020-12-20 14:28

    Firefox requires that a user run the dataTransfer.setData function in the event.

    For you jQuery users, that means the following code should resolve your issue:

    function dragstartHandler(event){
    
      event.originalEvent.dataTransfer.setData('text/plain', 'anything');
    
    }
    

    Future events on the same drag will now properly fire as you expected. Obviously you can replace the setData arguments with more useful data.

    0 讨论(0)
  • 2020-12-20 14:43

    According to https://developer.mozilla.org/en-US/docs/Web/Events/dragstart set data to null (like in html part of the example, or in the event function) with:

    event.dataTransfer.setData('text/plain', null);
    

    Chromium doesn't need of that.

    0 讨论(0)
提交回复
热议问题