DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Object.innerText For IE And FF

07.27.2005
| 12443 views |
  • submit to reddit
        
function getInnerText(elt) {
	var _innerText = elt.innerText;
	if (_innerText == undefined) {
  		_innerText = elt.innerHTML.replace(/<[^>]+>/g,"");
	}
	return _innerText;
}
Then, replace:
var text = elt.innerText;
by:
var text = getInnerText(elt);