Yun*_*zel 0 html javascript css
<div align="right" style="border:1 #FF0 solid; background-color:#999" onMouseOver="javascript: function(){this.style.backgroundColor = '#DDD';}" onMouseOut="javascript: function(){this.style.backgroundColor = '#999';}">
Register
</div>
Run Code Online (Sandbox Code Playgroud)
当mouseover事件触发时,会出现此错误:
未捕获的SyntaxError:意外的令牌(
我该怎么办?我想里面定义一个函数onMouseOver和onMouseOut
不要使用function声明,只需:
onMouseOver = "this.style.backgroundColor = '#DDD';"
Run Code Online (Sandbox Code Playgroud)
和:
onMouseOut = "this.style.backgroundColor = '#999';"
Run Code Online (Sandbox Code Playgroud)
顺便说一句,你应该考虑不引人注目的JavaScript.
| 归档时间: |
|
| 查看次数: |
7248 次 |
| 最近记录: |