Js问题
<div onClick= "this.style.color= 'red '; "> abc </div>
<br />
<div onClick= "this.style.color= 'red '; "> def </div>
如果实现,我点击过后,再占击其他的部分时,只有一个显示为红色?
------解决方案--------------------给个id,一个点击的时候再把另一个的color设为black
------解决方案-------------------- <div onClick= "if(window.redDiv)window.redDiv.style.color= 'black ';this.style.color= 'red ';window.redDiv=this; "> abc </div>
<br />
<div onClick= "if(window.redDiv)window.redDiv.style.color= 'black ';this.style.color= 'red ';window.redDiv=this; "> abc </div>
<br />
<div onClick= "if(window.redDiv)window.redDiv.style.color= 'black ';this.style.color= 'red ';window.redDiv=this; "> abc </div>
------解决方案-------------------- <div id= 'b ' onClick= "this.style.color= 'red ';document.all.a.style.color= ' '; "> abc </div>
<br />
<div id= 'a ' onClick= "this.style.color= 'red ';document.all.b.style.color= ' '; "> def </div>