Animate text updated by Jquery
Sorry for the simple question - can't seem to figure out what I'm doing wrong.
I have
$("div." + slot).html("<img width=\"64\" class=\"square\" src=\"" + data.newimg + " \">", function() {
$("div." + slot).fadeIn(2000); });
I would expect this callback function() to animate my DIV that I'm updating with new HTML (adding the image). It doesn't seem to do anything...
Thanks in advance.
----UPDATE-----
Shouldn't this work?
$("div." + slot)
.html("<img width=\"64\" class=\"square\" src=\"" + data.newimg + " \">")
.fadeIn(5000);
I also tried:
$("div." + slot)
.html("<img width=\"64\" class=\"square\"开发者_如何学编程 src=\"" + data.newimg + " \">")
$("div." + slot + " img").fadeIn(5000);
Neither seem to give any fade in effect...
.html() has no callback function
use it like this
$("div." + slot).html("<img width=\"64\" class=\"square\" src=\"" + data.newimg + " \">");
$("div." + slot).fadeIn(2000);
or
$("div." + slot)
.html("<img width=\"64\" class=\"square\" src=\"" + data.newimg + " \">")
.fadeIn(2000);
As genesis mentioned, html has no callback, have you tried:
$('div.'+slot).html('<img width="64" class="square" src="'+data.newimg+'">').fadeIn(5000);
If that doesn't work, the next thing I would check is to make sure your $('div.'+slot) exists at the time you try to change the html.
精彩评论