$(document).click(function(e){ //获取当前id var id = $(e.target).attr("id"); console.log(id); var currA = document.getElementById(id); var a=document.getElementsByTagName("div");//a是所有div数组 var b = []; var c = []; for(var i=0;i<a.length;i++){ b[i]=a[i].id; } for(var i =0,j=0;i<b.length;i++){ if(b[i]!="" && b[i]!=null && b[i]!="side_here_l" && b[i]!="side_here" && b[i]!="top_t" && b[i]!="bottom_bg" && b[i]!="photo_info" && b[i]!="base_info" && b[i]!="search" && b[i]!="background_search" && b[i]!="photo" && b[i]!="here_area" && b[i]!="here_area_back" && b[i]!="side" && b[i]!="main"){ c[j] = b[i]; j++; } } for(var i =0;i<c.length;i++){ //console.log(c[i]); } /** *id: *side_here_l side_here top_t bottom_bg photo_info base_info search background_search... *不予改变 */ if(id != "side_here_l" && id != "side_here" && id != "top_t" && id != "bottom_bg" && id != "photo_info" && id != "base_info" && id != "search" && id != "background_search" && id!="photo" && id!="here_area" && id!="here_area_back" && id!="side" && id!="main"){ $(currA).css('background-color',"#FFBBFF"); for(var i =0;i<c.length;i++){
//其他未点击的仍为背景色 if(id != c[i]){ var temp = document.getElementById(c[i]); //console.log(temp); $(temp).css('background-color','#EFF5F9'); } } } });