0
這是我的javascript與麻煩。點擊結合的if/else jQuery中
$(document).ready(function(){
$('.frontpageimg').click(function(){
$(this).data('clicked', true);
});
if('.frontpageimg').data('clicked') {
$('#imagepos').slideUp(2000).fadeOut(2000);
$('#contentpos').slideUp(2000).fadeIn(2000);
} else {
$('#imagepos').delay(8000).slideUp(2000).fadeOut(2000);
$('#contentpos').delay(8000).slideUp(2000).fadeIn(5000);
}
});
網站動畫顯示的延遲,這是什麼應該發生後的主要內容。但是,我希望用戶能夠通過點擊圖像跳過等待並激活較短的動畫。目前,「其他」部分下的所有內容都能正常工作,但點擊圖像時不會發生任何事情。
編輯:我已經改變了代碼,試圖讓事情工作,仍然沒有做我想做的事情。
$(document).ready(function(){
$('#imagepos').delay(8000).slideUp(2000).fadeOut(2000);
$('#contentpos').delay(8000).slideUp(2000).fadeIn(5000);
});
$('#frontpageimg').click(function(){
$('div:animated').stop();
$('div:animated').clearQueue();
$('#imagepos').slideUp(2000).fadeOut(2000);
$('#contentpos').slideUp(2000).fadeIn(2000);
});
有在你的代碼中是一個_syntax error_if if('。frontpageimg')' – undefined
不知道if/else塊中有什麼東西在工作,代碼執行應該會在if行中出錯並停止。 – MrOBrian
修復了語法錯誤,並且在解決當前的嘗試之前,圍繞一堆事情前進。它仍然不起作用,但不會拋出任何錯誤。 – MWhitmore