Kevin Reid's blog

.innerText and .textContent

 

new
Name
Kevin Reid
Website
My Website

.innerText and .textContent

Previous Entry Add to Memories Share Next Entry
new

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