Jquery - 为什么click()和.on(“click”)触发两次

时间:2013-01-20 06:11:50

标签: javascript jquery

为什么点击时会触发两次?它不会调用任何外部函数。结果是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);          
        });
}

0 个答案:

没有答案