ie6/ie7/ie8/ie9中tbody的innerhtml不能赋值,重现代码如下
两个按钮,第一个获取tbody的innerhtml,第二个设置tbody的innerhtml。
获取时所有浏览器都弹出了tr的字符串,但设置时ie6-9不支持,而且报错,如图
可以利用特性判断来看浏览器是否支持tbody的innerhtml设值
对于ie6-ie9里如果要设置tbody的innerhtml,可以使用如下替代方法
用一个div来包含一个table,然后删除tbody里的所有元素,最后给tbody添加div的第一个元素的第一个元素,即div>table>tr。
当然还有一个更精简的版本,它直接采用replacechild方法替换
从msdn上记录上看 col、colgroup、frameset、html、head、style、table、tfoot、thead、title和tr的innerhtml都是只读的(ie6-ie9)。
the innerhtml property is 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 title element using the document.title property.
to change the contents of the table, tfoot, thead, and tr elements, use the table object model described in building tables dynamically. however, to change the content of a particular cell, you can use innerhtml.
如对本文有疑问, 点击进行留言回复!!
清除新版Google Chrome浏览器中表单控件(input,button...)默认的黑色边框
荐 20200714——git/mac配置/项目运行步骤/一些报错
antd 菜单组件 使用时报错:Cannot read property ‘isRootMenu‘ of undefined
CSS|div的style=“background-image: url(img/a.bmp)图片显示不出来
硬件仪表盘账号建立指导(一) --WHQL认证测试结果提交账号(一)
cookie的规范Cookie的不可跨域名性或Cookie与域名的关系
网友评论