我有一個拖放項目來打印按鈕,其中一個按原樣打印頁面(在用戶拖拽或放下任何東西之前),另一個則在加載時使用JavaScript禁用。如何在所有可拖動對象被刪除後激活第二個按鈕?jQuery如何在多個隨機拖放事件之後觸發一個函數?
$(document).ready(function() {
$(".ui-widget-content").draggable({ revert: 'invalid', cursor: 'move', snapTolerance: '0px' }),
$("#dropcrown").droppable({ accept: '#crown'});
$("#dropneck").droppable({ accept: '#neck' });
$("#dropback").droppable({ accept: '#back' });
$("#droptail").droppable({ accept: '#tail' });
$("#dropwing").droppable({ accept: '#wing' });
$("#dropeye").droppable({ accept: '#eye' });
$("#dropbeak").droppable({ accept: '#beak' });
$("#dropcheek").droppable({ accept: '#cheek' });
$("#dropbreast").droppable({ accept: '#breast' });
$("#dropbelly").droppable({ accept: '#belly' });
$("#dropfoot").droppable({ accept: '#foot' });
$('#button2', this).attr('disabled', 'disabled');
$('#button2', this).addClass("ui-state-disabled");
});
$(document).ready(function() {
$("#dropcrown, #dropneck ,#dropback, #droptail, #dropwing, #dropeye, #dropbeak, #dropcheek, #dropbreast, #dropbelly, #dropfoot").droppable({tolerance:'touch',
drop: function(event, ui) {
$(this)
.addClass("ui-state-highlight");
var dropped = ui.draggable;
var droppedOn = $(this);
$(dropped).detach().css({top: 15,left: 7}).appendTo(droppedOn);
$('#button', this).attr('disabled', 'disabled');
$('#button', this).addClass("ui-state-disabled");
}
});
});
$(document).ready(function() {
if($('#labels').html() == ""){
$('#button2', this).removeAttr('disabled', 'disabled');
$('#button2', this).removeClass("ui-state-disabled");
//do something
}
});
請顯示一些代碼。 – 2012-04-14 15:53:56