[whatwg] Fwd: createElement convenience method

Garrett Smith dhtmlkitchen at gmail.com
Sat Oct 20 11:38:53 PDT 2007


On 10/20/07, Keryx Web <webmaster at keryx.se> wrote:
> Hello again!
>

> P.S In PHP I can also get the text between start- and end-tags of an
> element with
>
> element.nodeValue
>
> instead of
>
> element.firstChild.nodeValue
>
> Even if I've yet to see any bad repercussions from this convenient
> shortcut, I could imagine it is a bit more shaky...
>
try
element.textContent

IE doesn't support textContent, so you can write a simple adapter:

function getTextContent(el) {
    if(typeof el.textContent == "string")
        return el.textContent
    return el.innerText;
}
--
Programming is a collaborative art.


-- 
Programming is a collaborative art.



More information about the whatwg mailing list