js改变classname怎么不行啊

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:07:26
<!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>
<style>
.s1
{
background:#999;
}

.s2
{
background:#333;
}

input
{
width:100px;
height:20px;
border:solid 1px #0066FF;
}
</style>
</head>
<body>
<script>
function re()
{
var a=document.getElementById('ff');
a.className='s1';
a.onmouseover=new function

a.onmouseover=new function(){this.className='s2'}
a.onmouseout=new function(){this.className='s1'}

把这两句话中的new去掉

浏览器不同的话不一样,你试试设置class属性看看

请问一下这里的className是什么意思?可以为其赋值吗?是属性吗?