Javascript onMouseover交换图像 [英] Javascript onMouseover to swap images
本文介绍了Javascript onMouseover交换图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< script>< p>
函数bigImg(x)
{
x.style.height =70px;
x.style.width =237px;
}
函数normalImg(x)
{
x.style.height =56px;
x.style.width =218px;
}
< / script>
我用下面的函数调用这些函数:
< a取代;< IMG BORDER = 0 SRC = category_icons / addorder.png 的onmouseover = bigImg(这) 的onmouseout = normalImg(这) >< ; / A>
但是我真正想要做的就是让 bigIMG x)
函数也会更改图像。我对JavaScript并不是非常熟悉,并在想知道是否有人知道我可以编码,交换图像。图像名称是addorder2.png。我试过使用 this.src =addorder2.png;但这是行不通的。
解决方案
这样做。将图像src更改为addorder2.png。
< script>
函数bigImg(x)
{
x.style.height =70px;
x.style.width =237px;
x.src =addorder2.png;
}
函数normalImg(x)
{
x.style.height =56px;
x.style.width =218px;
x.src =addorder.png;
}
< / script>
I have some code that makes an image larger when moused over:
<script>
function bigImg(x)
{
x.style.height="70px";
x.style.width="237px";
}
function normalImg(x)
{
x.style.height="56px";
x.style.width="218px";
}
</script>
and I call those functions with:
<a><img border="0" src="category_icons/addorder.png" onmouseover="bigImg(this)" onmouseout="normalImg(this)"></a>
But what I would really like to do is make it so the bigIMG(x)
function also changes the image. I'm not extremely familiar with javascript and was wondering if someone knew what I can code in, to swap the image. The image name is addorder2.png. I've tried using this.src="addorder2.png"; but that is not working.
解决方案
This will do. Change the image src into "addorder2.png".
<script>
function bigImg(x)
{
x.style.height="70px";
x.style.width="237px";
x.src = "addorder2.png";
}
function normalImg(x)
{
x.style.height="56px";
x.style.width="218px";
x.src = " addorder.png";
}
</script>
这篇关于Javascript onMouseover交换图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文