0

为什么点击时会触发两次?它没有调用任何外部函数。结果是 offState 被触发了两次,否定了它的目的。click() 默认会触发两次吗?我也尝试.on('click', function()...过同样的结果。

function makeBackNav(){
    $('.backTitle').text("");
        //make back button's text the previously selected category
        $('.backTitle').append(prevLocation).click(function(){
            //need to swap images around so that they are activated on click
                var onState = $('#' + selectedCategory).find('img').first().attr('src');
                var offState = $('#' + selectedCategory).find('img').last().attr('src');
            $('#' + selectedCategory).find('img').last().attr('src', onState);
            console.log(offState);          
        });
}
4

0 回答 0