drag and drop not working in firefox

前端 未结 2 784
不思量自难忘°
不思量自难忘° 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    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.

提交回复
热议问题