inner-text
Cross Browser innerText
function based on innerHTML with replacements.
innerText is a function, that is not standardized, but Chrome and IE support. Firefox doesn't.
There is different ways to implement the innerText functionality.
You can get a selection
window.getSelection()
, select all the elementsselection.selectAllChildren(el)
and callselection.toString()
.The problem is, that it is based on the user selection, and you can mess it up.
If you want to go this route: inner-text-shim is for you.
Otherwise this function can be helpful.
install
npm install inner-text
usage
all innerText does is get the el.innerText
from the element
, even when the browser does not support it.
you can't set the innerText
with this module.
var innerText = ; // get the dom element with plain javascriptvar el = document;// or with jquery:el = 0; // set the innerHTML (only for this example)elinnerHTML = 'hello<br/>world'; var text = assert;
test
npm test
license
MIT
author
Andi Neck | @andineck