如果我将鼠标悬停在另一个div上,我想降低某些div的不透明度,但如果我停止将div悬停,则不透明度应该再次更改为1
。
HTML
<div id="feld1" onmouseover="show1()"> </div>
<div id="feld2" onmouseover="show2()"> </div>
<div id="feld3" onmouseover="show3()"> </div>
JS
function show1() {
if ($('#feld1:hover').length != 0) {
document.getElementById("feld2").style.opacity = 0.1;
document.getElementById("feld3").style.opacity = 0.1;
} else {
document.getElementById("feld2").style.opacity = 1;
document.getElementById("feld3").style.opacity = 1;
}
}
关于它如何运作的任何想法?
答案 0 :(得分:1)
好的,我明白了......
document.getElementById("feld1").onmouseover = function() {mouseOver()};
document.getElementById("feld1").onmouseout = function() {mouseOut()};
function mouseOver() {
document.getElementById("feld2").style.opacity = 0.1;
document.getElementById("feld3").style.opacity = 0.1;
}
function mouseOut() {
document.getElementById("feld2").style.opacity = 1;
document.getElementById("feld3").style.opacity = 1;
}