我正在使用代碼替換圖像,並在點擊某個元素時使用jquery添加/刪除類。當你第一次點擊的時候它工作正常,但是當你第二次點擊它時,它和第一個jquery點擊命令做同樣的事情,即使基於添加和刪除的類來調用點擊命令。 在我的示例中,只需找到光標變成指針的位置,然後單擊,將其指向底部中間,當您單擊該按鈕時,它將移動到光標上方,點擊它將淡出並進入,但會出現相同的圖像。用jquery替換圖像和類
請幫
//on arrow up click
//fade page out
//replace with open nav
$('.arrow_up').bind('click',function() {
$('.bg').fadeOut(500);
setTimeout(function(){
$('.bg').attr('src', 'other_files/images/bg_open_nav.png');
}, 500);
$('.bg').fadeIn(500);
$('.arrow').removeClass('arrow_up').addClass('arrow_down');
});
//on arrow down click
//fade page out
//replace with closed nav
$('.arrow_down').bind('click',function() {
$('.bg').fadeOut(500);
setTimeout(function(){
$('.bg').attr('src', 'other_files/images/bg.png');
}, 500);
$('.bg').fadeIn(500);
$('.arrow').removeClass('arrow_down').addClass('arrow_up');
});
您的演示不能正常工作,你甚至不具備的按鈕。 – QoP