javascript - jQuery append function not working in Internet Explorer 8 -


here code-

$("body").append("<div>" +                         "<ul>" +                             "<li>" +                                 "<a href='javascript:void(0)' onclick='add()'>add</a>" +                             "</li>" +                             "<li>" +                                 "<a href='javascript:void(0)' onclick='edit()'>edit</a>" +                             "</li>" +                             "<li>" +                                 "<a href='javascript:void(0)' onclick='delete()'>delete</a>" +                             "</li>" +                         "</ul>" +                     "</div>"); 

in ie8 getting following error - webpage error details

user agent: mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0) timestamp: wed, 27 mar 2013 07:03:53 utc  message: html parsing error: unable modify parent container element before child element closed (kb927917) line: 0 char: 0 code: 0 

you need after page load completed (because ie8 takes time render , javascript executed):

$(document).ready(function() {    $("body").append("<div>" +                     "<ul>" +                         "<li>" +                             "<a href='javascript:void(0)' onclick='add()'>add</a>" +                         "</li>" +                         "<li>" +                             "<a href='javascript:void(0)' onclick='edit()'>edit</a>" +                         "</li>" +                         "<li>" +                             "<a href='javascript:void(0)' onclick='delete()'>delete</a>" +                         "</li>" +                     "</ul>" +                 "</div>"); }); 

Comments