我有一個動畫函數,每次點擊一堆按鈕時都會發生,它們都會有特定的事情發生,但動畫會每次都發生。現在我已經設置好了,所以它是點擊的一部分,所以我重新定義了每次,我如何設置它一次,然後每個按鈕只是說點擊時運行該功能?在點擊事件期間設置稍後調用的函數
現在它設置爲這樣:
$("#animation1").click(function() {
$("#clinic_850_CONTAINER").animate({
height: box_TOTAL_ht + 20
}, 300);
$("#staff_850_CONTAINER").animate({
marginTop: staff_850_CONTAINER_ht * -1
}, 300);
$("#profile_850_HEADER").delay(160).animate({
top: 10
}, 270);
$("#profile_850_BIO").delay(330).animate({
top: profile_850_HEADER_ht + 20
}, 400);
$("#profile_850_EDU").delay(450).animate({
top: profile_850_HEADER_ht + profile_850_BIO_ht + 20
}, 400);
$("#profile_850_CONTACT").delay(570).animate({
top: profile_850_HEADER_ht + profile_850_BIO_ht + profile_850_EDU_ht + 20
}, 400);
});
設置它像這樣在頁面加載運行,你怎麼防止它從運行,直到點擊偏偏但讓他們單獨
function profile_850_close_animation() {
$("#staff_850_CONTAINER").animate({
marginTop: 0
}, 300);
$("#clinic_850_CONTAINER").animate({
height: staff_850_CONTAINER_ht
}, 300);
$("#profile_850_HEADER").animate({
top: box_TOTAL_ht + 20
}, 300);
$("#profile_850_BIO").animate({
top: box_TOTAL_ht + 50
}, 450);
$("#profile_850_EDU").animate({
top: box_TOTAL_ht + 60
}, 450);
$("#profile_850_CONTACT").animate({
top: box_TOTAL_ht + 70
}, 450);
}
$("#profile_850_CLOSE").click(profile_850_open_animation());
Arrrg,CAAAAAPS! – elclanrs
爲所有按鈕定義一個類,並將點擊處理程序綁定到該類 – Huangism