No puedo hacer que FadeIn funcione

I'm trying to get my background to fadeIn on button click, am I doing it correctly?

$(document).ready(function () {
        $('#d_clip_container').click(function() {
            $('#d_clip_button').css('background-image','url(img/steps.png)').fadeIn("slow");
        });
    });

preguntado el 08 de noviembre de 11 a las 13:11

What browser? Some older ones such as IE8 can't fade transparent PNGs. -

Can you show html stucture, or give not working live example? -

You'll probably need to have the background on a separate element and animate that element's opacity. -

3 Respuestas

is $("#d_clip_button") visible before you call .fadeIn() ?

if it's visible, .fadeIn() would do nothing..

respondido 08 nov., 11:17

Ah, yes it is. I want to fade the background on the button. - James Jeffery

then, you need to hide the background before you fade it in - Ya Zhuang

i think that isn really possible - Flo

Esto debería funcionar:

$(document).ready(function () {
 $('#d_clip_button').css({'background-image':'url(img/steps.png)','display':'none'});
        $('#d_clip_container').click(function() {
            $('#d_clip_button').fadeIn("slow");
        });
    });

respondido 08 nov., 11:17

You can't fadein background, you can fadein only HTML elements like the whole button.

Creo que el .animate() puede hacer el truco.

respondido 09 nov., 11:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.