IE里的attachEvent不好用啊, 谁来帮我改一改.

xiao7cn xiao7cn 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

注:不要用onmouseout=function(){}这种的,因为我要添加多个事件处理器.
---------------------






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script defer="defer">
function hightlight(obj)
{
obj.style.backgroundColor='#999999';
}
function normal(obj)
{
obj.style.backgroundColor='';
}
for(var i=1;i<=3;i++)
{
var obj = document.getElementById('item'+i);
obj.attachEvent('onmouseover',function(){hightlight(obj)});
obj.attachEvent('onmouseout',function(){normal(obj)});
}
</script>
</head>

<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td id="item1"> </td>
</tr>
<tr>
<td id="item2"> </td>
</tr>
<tr>
<td id="item3"> </td>
</tr>
</table>
</body>
</html>
...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
xiao7cn
JavaScript 87,984 成员 224,680 内容