onmouseover和onMouseOut又有问题?

yueyang 2004-08-02 05:25:22
var tablecon = document.all.tableid.tBodies.tbodyid;
var cell = tablecon.rows[1].cells[1];

cell.onmouseover=function(){ this.className="today"; }
这个可以运行
cell.onmouseout=function(){ this.className="today"; }
这个不运行?

cell.onmouseover=test();
function test(){this.className="today"; }
这样就不行了?
...全文
181 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yueyang 2004-08-03
  • 打赏
  • 举报
回复
up
yueyang 2004-08-02
  • 打赏
  • 举报
回复
cell.attachEvent("onmouseout",funName)
cell.attachEvent("onmouseover",funName2)
这个还是光改变最后一个表格的颜色,是不是每次总是传一样的值造成的。怎样给funName函数传递值呢?
cell.attachEvent("onmouseout",funName(1))这样就不行,该如何呢?
rootcn 2004-08-02
  • 打赏
  • 举报
回复
注册两个行不行?
cell.attachEvent("onmouseout",funName)
cell.attachEvent("onmouseover",funName2)

smallyear 2004-08-02
  • 打赏
  • 举报
回复
分開寫后this代表的對象已經變了
yueyang 2004-08-02
  • 打赏
  • 举报
回复
//cell.onmouseover=test();
//function test(){cell.className="today"; }//这样写的话,this指代的是本函数,而不是
还是不行。

cell.attachEvent("onmouseout",funName)
这个可以,但不管鼠标移出什么地方总是最下面的一个表格被改了颜色。
孟子E章 2004-08-02
  • 打赏
  • 举报
回复
用 cell.attachEvent("onmouseout",funName)
JK_10000 2004-08-02
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 2</title>
</head>

<body>


<table border="1" width="251" height="181" id=tableid >
<tr>
<td width="121" height="47">1</td>
<td width="114" height="47">2</td>
</tr>
<tr>
<td width="121" height="122">3</td>
<td width="114" height="122">mouseout</td>
</tr>
</table>


</body>

</html>
<script>
var tablecon = tableid;
var cell = tablecon.rows[1].cells[1];

cell.onmouseover=function(){ this.innerText="mouseover"; }

cell.onmouseout=function(){ this.innerText="mouseout"; }


//cell.onmouseover=test();
//function test(){this.className="today"; }//这样写的话,this指代的是本函数,而不是cell,所以不行

</script>
yueyang 2004-08-02
  • 打赏
  • 举报
回复
cell.onmouseout=function(){ this.className="today"; }
这个可以运行。

但下面那个把函数写在其他地方
cell.onmouseover=test();
function test(){this.className="today"; }
这样就不行了?

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧