当我单击并附加一个新的 div 调用 block2 时,可拖动的拖动和停止不起作用?
怎么解决??
演示:http: //jsfiddle.net/hbGkN/1/
HTML
<div id="btn"><input name="click" type="button" value="Click" /></div>
<div class="block1" style=" width:100px; height:100px; background:orange;">I am Block1</div>
JS
$('#btn').click(function(){
var $newDiv=$('<div class="block2" style=" width:100px; height:100px; background:green;">I am Block2</div>');
$( "#btn").parent().append($newDiv);
});
$('.block1').draggable({
drag: function() {
$('.block1').text('Drag Now!');
},
stop: function() {
$('.block1').text('Stop Now!');
}
});
$('.block2').draggable({
drag: function() {
$('.block2').text('Drag Now!');
},
stop: function() {
$('.block2').text('Stop Now!');
}
});