jquery append在ie和chrome下差别 $('img#'+obj).parent('li').append('<div class=bar></div>');$('.bar').show();ie下有效,chrome下无效,怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用jq吗?第一行添加了就自然会显示, 第二行还要显示干嘛?chrome调试下看看是什么错误? $('img#'+obj)$('#img'+obj) ??? 或者 加个setTimeout试试 setTimeout(function(){$('.bar').show();},0) 问个问题最好把demo贴全,很多情况和上下文是有关系,再说也不方便调试和重现问题。测试了,没发现什么问题,一切正常。<html><head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script></head><body> <li> <img id="image" src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" /> </li> <script> var obj = "image"; $('img#'+obj).parent('li').append('<div class=bar>有什么不对?</div>'); $('.bar').show(); </script></body></html> 这样的代码无法解释append方法没有兼容性问题~ for(i=0; i<(array.length-1); i++){ id = array[i].substr(0,10); $('div#photo ul').append('<li><img class=photo id=' + id + ' src=photo/'+dir+'/'+array[i]+' width=154 /></li>'); } var getObj = $('img.photo'); getObj.each(function(id) { var obj = this.id; $('img#'+obj).mouseover(function(){ $('.bar').remove(); $('img#'+obj).parent('li').append('<div class=bar></div>'); $('.bar').show(); $('.bar').click(function(){ $('#act')[0].value = 'photodel'; $('#photoname')[0].value = $('img#'+obj)[0].src.slice(-14); $('img#'+obj).parent('li').remove(); $('#act')[0].value = 'photodel'; $('#photopost').ajaxSubmit({ target: 'div#notice', url: 'post.php', success: function(msg) { if(msg!="OK"){ alert(msg); } } }); }); }); });这是代码 新浪微博点下一页改变了url但只局部刷新怎么做的 动态生成checkbox的问题 怎么知道页面可见内容的顶端到全页面的顶端的距离 这个JS在IE FF中运行为什么就会出错呢??opera可以 将HTML中表格转换为EXCEL 在线MSN问题 对列表框中增加、删除、修改数据? 斑竹和各位朋友,请帮忙看看,有关frame的问题 怎样不用刷新页可以更改网页中的内容? 我想做一个网页,实现文本分割,发送短消息! html全屏疑惑 这种点击小图,大图就变的代码谁有
第一行添加了就自然会显示, 第二行还要显示干嘛?
chrome调试下看看是什么错误?
$('#img'+obj) ???
或者 加个setTimeout试试 setTimeout(function(){$('.bar').show();
},0)
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<li>
<img id="image" src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" />
</li>
<script>
var obj = "image";
$('img#'+obj).parent('li').append('<div class=bar>有什么不对?</div>');
$('.bar').show();
</script>
</body>
</html>
append方法没有兼容性问题~
id = array[i].substr(0,10);
$('div#photo ul').append('<li><img class=photo id=' + id + ' src=photo/'+dir+'/'+array[i]+' width=154 /></li>');
}
var getObj = $('img.photo');
getObj.each(function(id) {
var obj = this.id;
$('img#'+obj).mouseover(function(){
$('.bar').remove();
$('img#'+obj).parent('li').append('<div class=bar></div>');
$('.bar').show();
$('.bar').click(function(){
$('#act')[0].value = 'photodel';
$('#photoname')[0].value = $('img#'+obj)[0].src.slice(-14);
$('img#'+obj).parent('li').remove();
$('#act')[0].value = 'photodel';
$('#photopost').ajaxSubmit({
target: 'div#notice',
url: 'post.php',
success: function(msg) {
if(msg!="OK"){
alert(msg);
}
}
});
});
});
});
这是代码