IE6/IE7/IE8/IE9 tbody innerHTML cannot be assigned, reproduce the code as follows
Copy the Code code as follows:
Tbody innerHTML in IE6-IE9 cannot copy a bug
GET SET
Two buttons, the first to get Tbody's innerHTML, and the second to set the Tbody innerHTML.
Obtained when all browsers pop up the TR string, but the settings ie6-9 not support, and error,
You can use the feature to determine whether the browser supports TBODY innerHTML setting values
Copy the Code code as follows:
var isupporttbodyinnerhtml = function () {
var table = document.createelement (' table ')
var tbody = document.createelement (' tbody ')
Table.appendchild (TBODY)
var Boo = True
try{
tbody.innerhtml = ' '
} catch (e) {
Boo = False
}
Return Boo
}()
Alert (isupporttbodyinnerhtml)
For IE6-IE9 if you want to set tbody innerHTML, you can use the following workaround
Copy the Code code as follows:
function settbodyinnerhtml (tbody, HTML) {
var div = document.createelement (' div ')
div.innerhtml = '
'
while (Tbody.firstchild) {
Tbody.removechild (Tbody.firstchild)
}
Tbody.appendchild (Div.firstChild.firstChild)
}
Use a div to include a table, then delete all the elements in the tbody, and finally add the first element of the first element of the div to Tbody, which is div>table>tr.
Of course there is a more streamlined version, which is replaced directly by the ReplaceChild method
Copy the Code code as follows:
function settbodyinnerhtml (tbody, HTML) {
var div = document.createelement (' div ')
div.innerhtml = '
'
Tbody.parentNode.replaceChild (Div.firstChild.firstChild, tbody)
}
The innerHTML of Col, Colgroup, frameset, HTML, head, style, table, TFOOT, THead, title, and TR are read-only (IE6-IE9) from the record on MSDN.
The InnerHTML property was read-only on the col, Colgroup, FrameSet, HTML, head, style, table, TBody, TFoot, THead, title, and TR objects.
You can change the value of the the title element using the Document.title property.
The contents of the table, TFoot, THead, and TR elements, use the Table object model described in Building table S dynamically. However, to change the content of a particular cells, you can use InnerHTML.