Document.createelement On Table,tr,td Tags Fails Ie8
As the title says, I'm having an issue with IE8 (works in FF and IE9). The following code doesn't produce any errors, and if I substitute div,ul,and li; it works. I did some search
Solution 1:
You can't use only createElement()
function to create table,
tr
, td
to create whole table element.
Instead you have to use insertRow()
, insertCell()
function of table Object
For Reference check this:
http://viralpatel.net/blogs/dynamically-add-remove-rows-in-html-table-using-javascript/
Edit:
Even I was thinking in the same way for IE issues ,
Buy I found that actually for createElement()
to work in IE7 you have to create tbody
object and append that to the table
object and tr
to that tbody
object
tb = document.createElement("tbody")
var tbody = document.createElement('tbody');
table.appendChild(tbody);
var table_row = document.createElement('tr');
tbody.appendChild(table_row)//
Solution 2:
just add <!DOCTYPE html>
in markup.
In IE7 and above default rendering without DOCTYPE is Quirks mode (IE5).
Solution 3:
try this:
var ele = document.getElementById('content');
var table = document.createElement('table');
ele.appendChild(table);
var tr = document.createElement('tr');
table.appendChild(tr);
var td = document.createElement('td');
tr.appendChild(td);
var txt = document.createTextNode('IE8');
td.appendChild(txt);
Post a Comment for "Document.createelement On Table,tr,td Tags Fails Ie8"