jQuery改变div背景颜色

<!DOCTYPEhtml><html><head>

Jquery效果,多个DIV,点击切换文字,变换背景颜色,再次点击或者点击其他div,文字和背景色变回来

css:/*原始背景色*/.bg{background:'red'}/*切换背景色*/.bg_click{background:'green'}js:$('div').on('click',function(){var$div=$(this);var$others=$div.siblings();if($div.hasClass('bg')){$div.removeClass('bg').html('要替换的文本');else{$div.removeClass('bg').html('原始文本');}$others.addClass('bg');').removeClass('bg_click').html('原文');}