Reputation: 527
I create a div on click of the 4 item in the second row. I would like to create a new draggable div like the first one. I'm sure it's the .draggable() that cause the problem.
I try many other place but can't figure out where to add the .draggable()
var i = 0;
$('#dropbtn').click(function() {
// insert a SPAN tag with class="spn" at the end in all DIVs with class="cls"
if(i == 0){
$('#dropbtn').append('<div class="boxArt red" row="2" col="4" id="dragme3">DRAG ME3</div>').draggable();
i=i+1;
}
});
Upvotes: 0
Views: 298
Reputation: 213
You are applying the .draggable()
at the wrong element. The .append()
method returns the container element, not what you added.
This should work:
$('<div class="boxArt red" row="2" col="4" id="dragme3">DRAG ME3</div>').draggable().appendTo('#dropbtn');
Upvotes: 1