Log in

No account? Create an account

Kevin Reid's blog

.innerText and .textContent


Kevin Reid
My Website

.innerText and .textContent

Previous Entry Share Next Entry

Today I learned that there is a standard-DOM alternative to the convenient IEism element.innerText (a close relative of element.innerHTML): element.textContent.

It is slightly different, according to MDN: .innerText returns the visible text (omitting scripts and CSS-hidden text), whereas .textContent returns everything, more like walking the document tree.

(This information crossed my awareness while working on Caja, but I didn't recognize it as something I could actually make use of until now.)

Powered by LiveJournal.com