我想改变'img'类中的'im'和'desc'类的属性。我将当前元素传递给javascript函数mOver()和mDown() 。当我鼠标悬停图像的边界以及文本它应该下面change.Here是我的代码:改变一个类的元素的属性
<html>
<head>
<style>
.img
{
margin:2px;
border:1px solid #0000ff;
height:90;
width:110;
float:left;
text-align:center;
}
.im
{
width:110px;
height:90px;
display:inline;
margin:3px;
border:1px solid #ffffff;
}
.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:2px;
}
</style>
<script>
function mOver(a)
{
a.style.border="10px solid #0000ff";
a.getElementByClassName("desc").innerHTML="Click on the image";
}
function mDown(a)
{
a.style.border="1px solid #ffffff";
a.getElementByClassName("desc").innerHTML="You have clicked already";
}
</script>
</head>
<body>
<div class="img" onmouseover="mOver(this)" onmouseout="mDown(this)">
<a target="_blank" href="abc.png">
<img class="im" src="abc.png"></a>
<div class="desc">ABC</div>
</div>
<div class="img" onmouseover="mOver(this)" onmouseout="mDown(this)">
<a target="_ blank" href="def.png">
<img class="im" src="def.png"></a>
<div class="desc">DEF</div>
</div>
</body>
</html>
图片下方的文字并没有改变,因为它应该有。 我觉得是有毛病线
a.getElementByClassName("desc").innerHTML="You have clicked already";
我是比较新的JavaScript所以请让我知道什么是错here.Anyways由于事先
它不应该是'getElementsByClassName'(复数)? – m90