Trying to make dynamically created element draggable

守給你的承諾、 提交于 2019-12-25 02:28:14

问题


I'm trying to create a dynamic input element that is draggable. Now the problem is I create an element but when I use something like

$("#in"+index.toString()).draggable({cancel:true});

after I append it to the container div, it's not working. Basically it's not working for the dynamically created input element of a certain id. Here's the code and please feel free to point out problems. I could really use some help on this one. Thanks!

http://jsfiddle.net/ithril/hRCun/5/


回答1:


The problem is that you are creating a new element that is not bound to the UI functions. I would suggest using clone(true,true) and then changing the parameters of the cloned element as need be. You can learn more about clone here. http://api.jquery.com/clone/



来源:https://stackoverflow.com/questions/7339543/trying-to-make-dynamically-created-element-draggable

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