javascript - document.createElement on table,tr,td tags fails IE8 -
as title says, i'm having issue ie8 (works in ff , ie9). following code doesn't produce errors, , if substitute div,ul,and li; works. did searching , didn't find on (table,tr,td) tags not being supported using document.createelement
ie8. going wrong?
here code:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>my page title</title> <script> function init() { var ele = document.getelementbyid('content'); var table = document.createelement('table'); var tr = document.createelement('tr'); var td = document.createelement('td'); var txt = document.createtextnode('ie8'); td.appendchild(txt); tr.appendchild(td); table.appendchild(tr); ele.appendchild(table); } </script> </head> <body onload="init();"> <div id="content"></div> </body> </html>
just add <!doctype html>
in markup. in ie7 , above default rendering without doctype quirks mode (ie5).
Comments
Post a Comment