window.onload = function(){
var oSkin = document.getElementsByTagName("li");
for(var i = 0; i < oSkin.length; i++){
oSkin[i].onclick = function() {
for(var p in oSkin){oSkin[p].className="";}
this.className = "current";
document.body.style.backgroundColor = this.id;
}
}
}
部分CSS
#skin li {
float: left;
width: 6px;
height: 6px;
margin-right: 10px;
cursor: pointer;/*k*/
text-indent: -9999px;/*k*/
border-width: 4px;
border-style: solid;
}
#skin li.current {background: #fff;}
知识点:
document.body.style.backgroundColor