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);
It results,
NaN
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 uses straight text, does not parse HTML, and is faster. innerText Takes styles into consideration.
textContents is all text contained by an element and all its children that are for formatting purposes only. innerText returns all text contained by an element and all its child elements. innerHtml returns all text, including html tags, that is contained by an element.
textContent gets the content of all elements, including <script> and <style> elements. In contrast, innerText only shows "human-readable" elements. textContent returns every element in the node. In contrast, innerText is aware of styling and won't return the text of "hidden" elements.
In JavaScript, there are various properties that can be used to access and modify the content of html tags i.e. textContent, innerText, and innerHTML. The textContent property returns all the text contained by an element/node and all of its descendants including spaces and CSS hidden text, except the tags.
textContent is not supported by IE7/8. The latter has a different property called innerText which returns the text contents of a DOM node.
Here is how to use both:
var text = e.item.textContent || e.item.innerText;
alert(text);
NOTE: e is html element
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With