Skip to content Skip to sidebar Skip to footer

JQuery Html() Doesn't Work Well In IE9

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 <

Solution 1:

"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())


Solution 2:

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.


Post a Comment for "JQuery Html() Doesn't Work Well In IE9"