W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2007

[whatwg] Fwd: createElement convenience method

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Sat, 20 Oct 2007 11:38:53 -0700
Message-ID: <c9e12660710201138n3da62fcgb61bc6f9b0fd2600@mail.gmail.com>
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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:37 UTC