我有問題用jQuery彈出頁腳。我的代碼是工作,但唯一的問題是它不起作用的第一次點擊按鈕,它通過第二次單擊按鈕工作?任何想法? 這裏是我的代碼:用jQuery在第一次點擊的網站上彈出頁腳?
<script type="text/javascript">
jQuery(function($) {
var open = false;
$('#footerSlideButton').click(function() {
if(open === false) {
$('#footerSlideContainer').animate({ height: '0' });
$(this).css('backgroundPosition', 'top left');
open = true;
} else {
$('#footerSlideContainer').animate({ height: '150px' });
$(this).css('backgroundPosition', 'bottom left');
open = false;
}
});
});
</script>
應該'VAR開放= true;'be'var open = false;'? –
備註:對於'if'語句,如果var是一個bool,你可以簡單地說'if(open)'爲真,'if(!open)'爲假 – Dom
oops。如果它是假的,也有同樣的問題。它通過第二次點擊按鈕來工作。我想用第一個點擊頁腳彈出...你認爲它與CSS有關嗎? – user2708492