求大神帮忙,想用jQuery+js写要给点击事件,判断背景是否要变色

2025-05-21 18:54:47
推荐回答(1个)
回答1:

$(function(){
    $('#div_title li').on('click',function(){
        if($(this).css('backgroundColor')=='red'){
             $(this).css("backgroundColor","");
        }else{
            $(this).css("backgroundColor","red");
        }
    });
});

试一试这样有没有问题