admin管理员组文章数量:1324847
I use jquery to request data and then fill them to a table whose id is 'mresholder', it works in webkit and ff but it doesn't work well in IE. It will append those data behind </table>
.
How to solve this or what's the alternative way to do this?
for(i=0;i<length;i++)
{
song=data.results[i];
o=$('#mresholder').html();
$('#mresholder').html(o+='<tr sid='+song.song_id+' aid='+song.album_id+'><td class="sname">'+song.song_name+'</td><td class="sartist">'+song.artist_name+'</td><td class="salbum">'+song.album_name+'</td></tr>');
};
I use jquery to request data and then fill them to a table whose id is 'mresholder', it works in webkit and ff but it doesn't work well in IE. It will append those data behind </table>
.
How to solve this or what's the alternative way to do this?
for(i=0;i<length;i++)
{
song=data.results[i];
o=$('#mresholder').html();
$('#mresholder').html(o+='<tr sid='+song.song_id+' aid='+song.album_id+'><td class="sname">'+song.song_name+'</td><td class="sartist">'+song.artist_name+'</td><td class="salbum">'+song.album_name+'</td></tr>');
};
Share
Improve this question
asked Sep 14, 2011 at 15:29
dotslashludotslashlu
3,4015 gold badges33 silver badges58 bronze badges
2
- 3 Can we see the related HTML as well, please? – Matt Gibson Commented Sep 14, 2011 at 15:30
-
It sounds like
#mresholder
is another element that contains the table you want to append to rather than the table itself. If that's the case, try editing your search to$('#mresholder table')
. – Jonathan Lonowski Commented Sep 14, 2011 at 15:36
2 Answers
Reset to default 8"sid", "aid" aren't valid HTML attributes. Try data-sid, data-aid
also, change
o=$('#mresholder').html();
$('#mresholder').html(o+='<tr sid='+song.song_id+' aid='+song.album_id+'><td class="sname">'+song.song_name+'</td><td class="sartist">'+song.artist_name+'</td><td class="salbum">'+song.album_name+'</td></tr>');
to
$('#mresholder').append('<tr data-sid='+song.song_id+' data-aid='+song.album_id+'><td class="sname">'+song.song_name+'</td><td class="sartist">'+song.artist_name+'</td><td class="salbum">'+song.album_name+'</td></tr>');
(.html() to .append())
Try using append
instead.
$('#mresholder').append('<tr sid='+song.song_id+' aid='+song.album_id+'>'...);
Also, check the HTML that you're adding, IE has a problem when adding HTML to a table if it's not valid. Try @genesis' suggestion, and change sid
and aid
to data-sid
and data-aid
, too.
本文标签: javascriptjQuery html() doesn39t work well in IE9Stack Overflow
版权声明:本文标题:javascript - jQuery html() doesn't work well in IE9 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742149498a2422945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论