<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
li { list-style:none; width:114px; height:140px; background:url(img/normal.png); float:left; margin-right:20px; }
</style>
script>
window.onload = function (){
var aLi=document.getElementsByTagName('li');
for (var i = 0;aLi.length>i;i++){
aLi[i].onoff=true;//自定义的属性
aLi[i].onclick=function () {
if(this.onoff){
this.style.background='url(img/active.png)';
this.onoff=false;
}else {
this.style.background = 'url(img/normal.png)';
this.onoff = true;
}
}
}
};
</script>
</head><body><ul> <li></li> <li></li> <li></li></ul></body></html>