我正在尝试使用鼠标坐标来控制div元素的不透明度,但只有一个div元素会响应。
<head>
document.onmousemove=getMouseCoordinates;
function getMouseCoordinates(event)
{
ev = event || window.event;
var width = window.innerWidth;
document.getElementById('divOne').style.opacity = ev.pageX/width;
document.getElementById('divOne').style.filter = 'alpha(opacity=' + value*10 + ')';
document.getElementById('divTwo').style.opacity = ev.pageX/width;
document.getElementById('divTwo').style.filter = 'alpha(opacity=' + value*10 + ')';
}
</head>
<body>
<div id="divOne" style="position:fixed; top:7%; left: 11%;"><img src="images/skytest.png" /></div>
<div id="divTwo" style="position:fixed; top:22%; left: 26%;"><img src="images/0816112011d.jpeg" /></div>