Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29027

Re: Element output in JavaScript consoles

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: Element output in JavaScript consoles
Date 2015-12-19 13:11 -0200
Organization Aioe.org NNTP Server
Message-ID <n53s25$7q6$1@speranza.aioe.org> (permalink)
References <consoles-20151214163101@ram.dialup.fu-berlin.de> <nodeType-20151214175705@ram.dialup.fu-berlin.de> <n53k3t$mp0$1@speranza.aioe.org>

Show all headers | View raw


On 12/19/2015 10:55 AM, Joao Rodrigues wrote:
> On 12/14/2015 02:57 PM, Stefan Ram wrote:
>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>> document.firstElementChild
>>> <html>
>>
>>    Ok, my preceding question has become less important
>>    to me, because I now believe that for the first examples
>>    a member with a primitive type is better, so I now use
>>
>> document.nodeType
>>
>
> node.firstElementChild is well supported by modern browsers [1], but it
> only returns the first child that is an element (nodeType = 1), and null
> otherwise. [1]
              ^^^
        meant [2]

>
> [1] <http://www.quirksmode.org/dom/w3c_traversal.html>
> [2] <http://www.w3.org/TR/ElementTraversal/#attribute-firstElementChild>
>
>

You may try this in console (FF, Chrome):

var all = document.querySelectorAll('*');
[].forEach.call(all,
   item => {
     var ret = item.firstElementChild;
     if (ret) console.log(ret);
   }
);


-- 
Joao Rodrigues

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Element output in JavaScript consoles Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-12-19 10:55 -0200
  Re: Element output in JavaScript consoles Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-12-19 13:11 -0200

csiph-web