Why doesn't jquery fadeIn() work with .html()?

前端 未结 3 1187
悲&欢浪女
悲&欢浪女 2020-11-30 21:55

When you click you a checkbox I want the message to fade in slowly.

Why doesn\'t .fadeIn() work in this example?

HTML:

相关标签:
3条回答
  • 2020-11-30 22:11

    after analize this problem, that I have to solve, this is my code, that works to use fadeout, change html and fadein

    $("#div_big_picture").fadeOut('slow',function(){
        $(this).html("<img src='" + str_to_load + "' height='800px' />")
    }).fadeIn("slow");
    
    0 讨论(0)
  • 2020-11-30 22:28

    No idea why but I've had trouble chaining this before. You can get the effect you want by using this less elegant code:

    google.load("jquery", "1.3.2");
    
    //run when page is loaded
    google.setOnLoadCallback(function() {
    
        $('.checkboxList .row').css('color','red');
        $('.checkboxList input').attr('checked', true);
        $('.checkboxList input').bind('click', function() {
            $('#message').hide(); //just in case
            $('#message').html("You clicked on a checkbox.");
            $('#message').fadeIn('slow');
        });
    
    });
    
    0 讨论(0)
  • 2020-11-30 22:31

    No fadeIn is done because the #message element is visible, hide it, add the content and fade it in:

    $('#message').hide().html("You clicked on a checkbox.").fadeIn('slow');
    
    0 讨论(0)
提交回复
热议问题