Drag and Drop HTML (placeholder)

不问归期 提交于 2020-01-15 08:50:49

问题


Can anyone help me with drag and drop placeholder. I have 2 row's (left-right), each of them have 5 items.

I want to show the placeholder (border-style: dotted;) with neat animation. Soo.. before i drop the item i want to show the border.

Below you can find the example that im using from w3school

https://www.w3schools.com/html/html5_draganddrop.asp

How i want it to look!


回答1:


If you use plain javascript:

I created this solution on w3schools for you:

https://www.w3schools.com/code/tryit.asp?filename=FRCFSRF5F4RW

See the ondragstart and ondragend. The functions called there, set the border to the dotted one or back to the solid one. You can plac with the css value of course, but this is the basic implementation.

If you use jQuery ui drag:

Use the "drag" event in jQuery draggable:

$( "#draggable" ).draggable({
  drag: function() {
    $("#YOUR_PLACEHOLDER").css("border", "1px dotted black");
  }
});

see here for more information: https://jqueryui.com/draggable/#events



来源:https://stackoverflow.com/questions/50350167/drag-and-drop-html-placeholder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!