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