Trying to make dynamically created element draggab

2019-09-09 06:32发布

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条回答
SAY GOODBYE
2楼-- · 2019-09-09 06:58

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/

查看更多
登录 后发表回答