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".
Use callback.
$(".showvideothumbs").append('<img src="/garageimages/'+data.thumb+'" style="display:none;"/>').find('img').fadeIn(2000,function(){
$(this).css('display', 'inline');
});
Instead of inline style try
.css('display', 'inline')
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);
精彩评论