In my project im creating dynamically divs with jquery everytime you click a button. Now i want these new divs to have draggable and resizable properties. Here is what ive done so far:
$("#button1").click(function(){
$("<div/>", {
"id": "test",
text: "",
}).appendTo("body");
$( "#test" ).resizable();
$( "#test" ).draggable();
});
This code works somehow, the problem is that only the first div that was created is resizable and draggable.
Also is it possible to put another button in order to delete these new created divs?
idmust be unique! you create multiple divs with the sametestid => INVALID HTMLAnother thing, you don’t need to query the DOM, you can use the reference you got to make the created
<div>resizableanddraggable:If you want to use id for some reason:
#idselector comment in the docs site: