设置图像可动态拖动
Set image draggable dynamically
我有问题设置我的图像是可拖动的。这段代码似乎不起作用:
var thumb = document.createElement("img");
thumb.setAttribute('draggable', "true");
我创建并添加我的图像到DOM像这样:var thumb = document.createElement("img");
thumb.setAttribute('draggable', "true");
thumb.setAttribute('alt', label);
thumb.setAttribute('id', "dhmvseries_" + label);
thumb.setAttribute("dhmvseriesuuid",label);
thumb.ondragstart = thumbDragStart;
thumb.ondragend = thumbDragEnd;
thumb.onmouseover = displayThumbInfo;
thumb.onmouseout = hideThumbInfo;
var thinner = createElement("div", "dhThumbImage dhRounded");
thinner.appendChild(thumb);
我在我正在构建的用于闭包编译器的公共域库中使用它们。
/** drag(node n, property p)
* sets dataTransfer text to value of property p when node n is dragged
**/
function drag(n,p){n['draggable']=1
n['ondragstart']=function(a){a.dataTransfer.setData("Text",a.target?a.target[p]:a.srcElement[p])}}
/** drop(node n, function f)
* sets a drop event handler for node n that uses function f as its handler
* function f will be passed: the target node and the dataTransfer "Text" value
ex. var f=function(t,s){t.style.backgroundColor=s} //sets background the Text value
* * the "Text" is set to the value of property p in the drag event
* see drag(node n, property p)
**/
function drop(n,f){n['ondragover']=F
n['ondrop']=function(a){f(n,a.dataTransfer.getData("Text"))
return!!0}}
相关文章:
- 如何动态操作jquery可拖动UL元素的内容
- 无法拖动动态添加的 DIV
- 通过拖动移动动态创建的 DIV
- 动态 JS 拖动绑定函数限制在线拖动
- 网格员动态添加的小部件使可拖动
- 如何使动态创建的元素可拖动()
- jQuery动态拖动
- 具有可拖动列的动态淘汰Javascript表danvk
- 动态添加的 DIV,具有拖动和调整大小功能
- 拖动后在jquery中动态更改比例的变换原点
- 创建可拖动的动态
- Jquery dragtable动态添加的列拖动选项不工作
- 使动态绘制的元素可拖动
- 在动态JS中加载多个图像时可拖动的问题
- 动态添加的可拖动对象第一次不工作
- 动态JS拖动一个图层会导致另一个图层上的形状对拖动停止响应
- 告诉jquery draggable是动态拖动的
- 通过angularjs拖动动态更改模板
- 更新高度,宽度和jquery动态文本区域的样式,可拖动和可调整大小
- 设置图像可动态拖动