这个javascript老报错说Element未定义。。。请问如何改一下??

benefactor 2007-01-12 01:43:37
<html>
<head>
<style type="text/css">
.style1{
color:red;
}

.style2{
color:blue;
}

</style>



</head>

<body>
<form name="f">
<a href="#" id="tag1" class="style1" onclick="javascript:changeStyle('1');">Hello</a>
</form>
</body>

</html>

<script language="javascript">
function changeStyle(oid){
Element.removeClassName($('tag' + oid),"style1");
Element.addClassName($('tag' + oid),"style2");
}
</script>
...全文
486 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiao7cn 2007-01-12
  • 打赏
  • 举报
回复
没有你这样用的.这样就行了
-------------------
<html>
<head>
<style type="text/css">
.style1{
color:red;
}

.style2{
color:blue;
}

</style>



</head>

<body>
<form name="f">
<a href="#" id="tag1" class="style1" onClick="changeStyle(this);">Hello</a>
</form>
</body>

</html>

<script language="javascript">
function changeStyle(oid){
oid.className="style2";
}
</script>

87,910

社区成员

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

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