How to fadeIn my image into the container?

I want to show my image into the imageContainer but I can't do it with my code. Here is my code:

document.getElementById("imageContainer").innerHTML='<img src="'+data[3].pic+' " class= "imgbig">';

I tried something like this but not working.

$(document.getElementById("imageContainer").innerHTML='<img src="'+data[3].pic+' " class= "imgbig">').fadeIn("slow");

How do I accomplish this?

Answers:

Answer

Try to use .appendTo() for getting back the object of appended one,

$('<img>', {'src': data[3].pic, 'class' : 'imgbig'})
      .appendTo("#imageContainer")
        .hide().fadeIn("slow");
Answer

Being a bit more verbose and jQuery'ish probably helps

var img = $('<img />', {
              src     : data[3].pic,
              'class' : 'imgbig'
          });

img.hide();

$('#imageContainer').html(img);

img.fadeIn('slow');

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.