[whatwg] document.head
Juriy Zaytsev
kangax.dev at gmail.com
Sun Sep 20 13:24:42 PDT 2009
On Sep 20, 2009, at 4:15 PM, Joseph Pecoraro wrote:
> On Sep 20, 2009, at 3:57 PM, Michael A. Puls II wrote:
>> I think it'd be cool to have to complement document.documentElement
>> and document.body.
>
> On Sep 20, 2009, at 4: 00PM, Juriy Zaytsev wrote:
>> Surely better than abominable – `document.getElementsByTagName
>> ('head')[0]` :)
>
> I agree. Unfortunately that is the most popular method I've seen.
> There are better solutions, but they haven't caught on. I think a
> smarter idea would be to look at the children of the <html>
> element. Something like this almost always works:
>
> var head = document.documentElement.firstChild
Yep, I've seen that too. That's slightly better (i.e. less verbose)
than `gEBTN` -based approach (although less descriptive too).
Speaking of `document.head`, I think Mootools does exactly that.
--
kangax
More information about the whatwg
mailing list