$(document).off("click", "#main").on("click", "#main", function() {
that = $(this);
$('loading').show();
Delay = setInterval(function() {
getMenu(that.attr("menu_id"));
}, 1000);
});
如何臨時關閉#main的事件事件?因爲如果在加載期間沒有#main是可點擊的,並且導致我的函數執行多次。off()在jquery中臨時關閉事件
你可以使用'$(「#主」)解除綁定(「點擊」);'來解除綁定事件並用定時器重新綁定它? – 2015-02-12 01:53:04
@AlejandroIván'.off'代替'.unbind',就像'.on'代替'.bind'一樣。 – Barmar 2015-02-12 01:53:30
@Barmar謝謝我不知道,我有一段時間沒有編碼:) – 2015-02-12 01:56:20