日期:2014-05-16  浏览次数:20409 次

问下为什么我 inserAfter 插入没有效果 jquery
JScript code
showMsg = function(data) {
var time = $('<span style="color:red;></span>').html(data.time+'&nbsp;&nbsp;');
var username = $('<span style="color:blue;"></span>').html(data.username+'&nbsp;&nbsp;');
var say = $('<span style="color:black;"></span>').html('say:&nbsp;&nbsp;');
var msg = $('<span style="color:green"></span>').html(data.msg);
var div = $('<div style="display:none;></div>').append(time).append(username).append(say).append(msg);
alert(div);
div.insertAfter('#demo span:eq(0)'); //fadeIn();
}; 

上面是我的JS代码
下面是我的HTML代码
HTML code
<div id='demo' style="border:1px; border-style:dotted; width:800px; height:300px; overflow:auto;">
<span>...</span>
</div>



求教


------解决方案--------------------
昏,楼主的双引号 省略得,,,不仔细还真看不出来

showMsg = function(data) {
var time = $('<span style="color:red;"></span>').html(data.time+'&nbsp;&nbsp;');
var username = $('<span style="color:blue;"></span>').html(data.username+'&nbsp;&nbsp;');
var say = $('<span style="color:black;"></span>').html('say:&nbsp;&nbsp;');
var msg = $('<span style="color:green"></span>').html(data.msg);
var div = $('<div style="display:none1;"></div>').append(time).append(username).append(say).append(msg);
alert(div);
div.insertAfter('#demo span:eq(0)'); //fadeIn();
}; 



暂时把none去掉,不然看不到效果
------解决方案--------------------
style="display:none
这句把它设置为不显示,所以没效果