2
我正在寻找一个优雅的解决方案,淡入淡出HTML元素onmouseover在mouseout而不使用jQuery(叫我老式)。onmouseover onmouseout fadeIn fadeOut没有jQuery
从理论上讲,下面的js解决方案应该可以工作,但是我在工作时遇到问题,有人可能会指向正确的方向或提供替代解决方案吗?
我的js功能和插入HTML是一样的,其在页面上...
function fadeIn(element) {
for (i = 0; i < 100; i++) {
var value = 0 + i;
element.style.opacity = value;
element.style.filter = 'alpha(opacity=' + value + ')';
}
}
function fadeOut(element) {
for (i = 0; i < 100; i++) {
var value = 100 - i;
element.style.opacity = value;
element.style.filter = 'alpha(opacity=' + value + ')';
element.innerHTML = "<div class='container' id='container' onmouseover='fadeOut(this)'><img src='./images/myImage.jpg' onload='fadeIn(this.parent)' /></div>";
}
}
jQuery :-P库使生活更轻松。 – 2012-04-25 04:10:09
>优雅的解决方案 >在没有使用jQuery的情况下淡入淡出HTML元素onmouseover on mouseout > 选择任意2 – Cheezmeister 2012-04-25 04:11:13