[whatwg] Fwd: createElement convenience method

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.

Received on Saturday, 20 October 2007 11:38:53 UTC