Javascript textContent在IE8或IE7中不工作 [英] Javascript textContent is not working in IE8 or IE7
本文介绍了Javascript textContent在IE8或IE7中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要添加一个表的2个单元格内容并显示它。下面的JavaScript命令在chrome或IE10工作正常。 但不能在IE8或7中工作。
I need to add 2 cell content of a table and display it. Below JavaScript command works fine in chrome or IE10. But not working in IE8 or 7.
parseFloat(document.getElementById("total").textContent).toFixed(2);
结果,
NaN
您能告诉我什么是IE7中的或IE8 读取表格的单元格内容并将其转换为float然后添加..
Could you please tell me what is the equivalent command in IE7 or IE8 to read cell content of a table and convert it to float then add..
推荐答案
textContent 不受支持IE7 / 8。后者有一个不同的属性,称为innerText,返回一个DOM节点的文本内容。
textContent is not supported by IE7/8. The latter has a different property called innerText which returns the text contents of a DOM node.
这里是如何使用两个:
var text = e.item.textContent || e.item.innerText;
alert(text);
注意:e是html元素
这篇关于Javascript textContent在IE8或IE7中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文