语法:
实例:
html部分:div id="lock" class="lock" >开始</div>
css部分:.lock{width: 200px;height: 30px;line-height:30px;background: #00f ;color: blueviolet;} .unlock{width: 200px;height: 30px;line-height:30px;background:red ;color: blueviolet;}
js部分:
var but=document.getElementById("lock");
but.onclick=function(){
if(this.className=="lock"){
this.className="unlock";
this.innerHTML="结束";
}else{
this.className="lock";
this.innerHTML="开始";
}}
例子的具体含义是点击开始变色,变成结束,电击结束变成开始