我在 Chrome 上遇到 JavaScript 错误,例如
Uncaught TypeError: Object #<HTMLInputElement> has no method 'removeNode'
我的代码是
if (document.form["act[" + actArry["'" + i + "'"][i] + "]"] != undefined)
document.form["act[" + actArry["'" + i + "'"][i] + "]"].removeNode(true);
以及存储在 input
中的值元素是
<input type="hidden" name="act[1]" value="7813e7-true">
其实我想删除-true
当checkbox
是 unchecked
.
这在 IE 中可以正常工作,但在 Google Chrome 中却不能。
谁能告诉我问题是什么以及哪个应该是 IE 和 Chrome 中的通用方法? jQuery 有替代方案吗?
最佳答案
removeNode()
是仅 IE 的方法。它不适用于其他浏览器。
你可以做removeChild()
在父节点上实现相同的功能以及跨浏览器。
即:
if (node.parentNode)
node.parentNode.removeChild(node);
引用号:http://www.sitepoint.com/forums/showthread.php?126312-Mozilla-equivalent-for-IE-s-removeNode()
关于JavaScript 错误 "Uncaught TypeError: Object #<HTMLInputElement> has no method ' 删除节点'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16706595/