1. Imitar el desvanecimiento en (), Fade Out ().
Principio: Función SetInterval ("Opacidad ++ Transparencia", Intervalo de tiempo)
var alfa = 0; function play () {timer = setInterval (function () {alpha + = 2; alfa> 100 && (alfa = 100); aimg [index] .style.opacity = alfa / 100; aimg [index] .Style.filter = "Alpha (opacity =" + alpha / 100 + ")"; alpha == 100 &= 100 &&&&&&&&2 ClearInterval (temporizador);}, 40)}2. Obtenga y establezca el valor de atributo del objeto Elemento:
Puntos clave: obj.CurrentStyle [attr]; getComputedStyle (obj, null) [attr];
function css (obj, attr, val) {switch (arguments.length) {case 2: if (typeof arguments [1] == "string") {return obj.CurrentStyle? obj.CurrentStyle [attr]: getComputedStyle (obj, null) [attr];} else {para (var i en attr) {obj.Style [i] = attr [i];}} ruptura; caso 3: obj.style [attr] = val; ruptura; default: alerta ("parámetro de error");}}Lo anterior es el contenido relevante del código de función JS destacado por el editor. ¡Espero que te sea útil!