嘿傢伙這是我當前代碼的一個片段。我想知道如何將「onFinish或Finished」事件監聽器添加到此代碼中。jQuery中的onfinish事件監聽器/ javascript
這是setStage功能
function setStage($section)
{
switch($section)
{
case "about":
if (stageSet == true)
{
resetStage();
}
$("#one").animate({ width: "+=30", height: "+=30"}, 1000);
$("#two").animate({ width: "+=30", height: "+=30"}, 1000);
$("#three").animate({ height: "+=30"}, 1000);
$("#four").animate({ width: "+=30"}, 1000);
$("#five").animate({ width: "+=30"}, 1000);
stageSet = true;
break;
case "portfolio":
if (stageSet == true)
{
resetStage();
}
$("#one").animate({ width: "+=30", height: "+=30"}, 1000);
$("#two").animate({ width: "+=30", height: "+=30"}, 1000);
$("#three").animate({ height: "+=30"}, 1000);
$("#four").animate({ width: "+=30"}, 1000);
$("#five").animate({ width: "+=30"}, 1000);
stageSet = true;
break;
case "contact":
if (stageSet == true)
{
resetStage();
};
$("#one").animate({ width: "+=30", height: "+=30"}, 1000);
$("#two").animate({ width: "+=30", height: "+=30"}, 1000);
$("#three").animate({ height: "+=30"}, 1000);
$("#four").animate({ width: "+=30"}, 1000);
$("#five").animate({ width: "+=30"}, 1000);
stageSet = true;
break;
case "resume":
if (stageSet == true)
{
resetStage();
}
$("#one").animate({ width: "+=30", height: "+=30"}, 1000);
$("#two").animate({ width: "+=30", height: "+=30"}, 1000);
$("#three").animate({ height: "+=30"}, 1000);
$("#four").animate({ width: "+=30"}, 1000);
$("#five").animate({ width: "+=30"}, 1000);
stageSet = true;
break;
default:
alert('not a valid section');
break;
}
}
每個機箱內的動畫將是獨一無二的,但我只是做動畫,現在是相同的。以下是點擊發生的情況。我需要做的是應用類「關」到每個資產淨值,這是的話,然後當setStage完成我需要它起飛類
$(".nav-btn").click(function()
{
var section = $(this).attr("title");
//turn off pointer for obsessive clickers
$(".nav-btn").addClass("off");
onComplete: function(setStage(section)
{
$(".nav-btn").removeClass("off");
});
});
這當然行不通的。 setStage函數效果很好,我想要做的是在函數結束時刪除類。我檢查了jQuery網站上的api事件部分,並沒有看到任何足夠的東西,也許我只是不夠努力。 http://api.jquery.com/category/events/或者我在一起看錯了部分。有什麼想法嗎?提前感謝您幫助我降低我的不速之客。
刪除什麼類,何時完成什麼功能? 'setStage'是做什麼的? –
你去馬特,我需要它做這樣的事情。 – Brodie