Im卡住了,Im在某人點擊時設置了一個變量,然後測試了是否存在該變量並執行其他操作。它的一個簡單的腳本,我可能會過時,會喜歡某人的想法。jQuery交換點擊圖像和if/else
$('.view-alternatives-btn').live('click', function() {
//$("#nc-alternate-wines").scrollTo();
//$('.nc-remove').toggle();
var showBtn = null;
if (showBtn == null) {
$('.view-alternatives-btn img').attr("src","../images/wsj_hide_alternatives_btn.gif");
$('#nc-alternate-wines').show();
showBtn = 1;
console.log(showBtn);
}
else if (showBtn == 1) {
$('.view-alternatives-btn img').attr("src","../images/wsj_view_alternatives_btn.gif");
$('#nc-alternate-wines').hide();
console.log("this " + showBtn);
}
return false;
});
如果按鈕被點擊3次會怎樣? – SLaks 2010-06-02 13:24:23