Reputation: 1054
I'm trying to add images to a div. When the images append. The are displaying "block". I need them to display inline.
This is the code I am running:
$(".showvideothumbs").append($('<img src="/garageimages/'+data.thumb+'" style="display:inline">').hide().fadeIn(2000));
I've tried wrapping it in a div that has "display:inline" set, but jquery changes that to "display:block".
Upvotes: 0
Views: 5476
Reputation: 5659
Use callback.
$(".showvideothumbs").append('<img src="/garageimages/'+data.thumb+'" style="display:none;"/>').find('img').fadeIn(2000,function(){
$(this).css('display', 'inline');
});
Upvotes: 1
Reputation: 30498
I'm a little confused as to why you are doing this:
$('<img src="/garageimages/'+data.thumb+'" style="display:inline">').hide().fadeIn(2000)
You are, in effect, creating an image and then hiding and showing it before it is even added to the DOM.
Does setting the style using .css('display', 'inline')
work more effectively for you?
$(".showvideothumbs").append($('<img src="/garageimages/'+data.thumb+'" style="display:inline">').css('display', 'inline'));
You can then apply the hide/fade to the containing DIV (formatted for greater ease of reading):
$(".showvideothumbs")
.append($('<img src="/garageimages/'+data.thumb+'" style="display:inline">')
.css('display', 'inline'))
.hide().fadeIn(2000);
Upvotes: 0