如何添加宽度/高度的JavaScript命令"onmouseover"

How to add width/height to JavaScript command "onmouseover"

本文关键字:quot JavaScript 命令 onmouseover 高度 何添加 添加      更新时间:2023-09-26

如何在命令onmouseover中添加宽度/高度?例子:

onMouseOver="if (document.images) document.getElementById('Image-Maps_3201302221606237').src= 'images/rhs2.png';"
onMouseOut="if (document.images) document.getElementById('Image-Maps_3201302221606237').src='images/high_schools.gif';">

当鼠标经过某个元素时,我需要显示的图像具有一定的宽度或高度?

OK给你一个更清晰的图片我想要完成的,我有一个图片,是静态的不同的图标在它上面,每个图标有一个链接基于它从图像中获取的坐标,我希望当鼠标移到地图上的某个坐标上时图标会变大或者另一个图像出现在比静态图像上的图标大一点的坐标上这样就能产生使它变大的效果当鼠标移开时,新图片就会消失,这里是代码

https://www.dropbox.com/s/q587j5nizg9r5m6/file.html

.src='images/rhs2.png后添加

document.getElementById('the-id').style.height = certainHeight;

对width做类似的操作。

我也强烈建议你放弃on事件属性,并使用JavaScript来绑定:

document.getElementById('Image-Maps_3201302221606237').addEventListener(
    'mouseover', function () {
    this.src = newSrc;
    this.style.height = certainHeight;
    this.style.width = certainWidth;
});