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


Groups > comp.lang.javascript > #29026 > unrolled thread

Re: Element output in JavaScript consoles

Started byJoao Rodrigues <groups_jr-1@yahoo.com.br>
First post2015-12-19 10:55 -0200
Last post2015-12-19 13:11 -0200
Articles 2 — 1 participant

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#29026 — Re: Element output in JavaScript consoles

FromJoao Rodrigues <groups_jr-1@yahoo.com.br>
Date2015-12-19 10:55 -0200
SubjectRe: Element output in JavaScript consoles
Message-ID<n53k3t$mp0$1@speranza.aioe.org>
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]

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



-- 
Joao Rodrigues

[toc] | [next] | [standalone]


#29027

FromJoao Rodrigues <groups_jr-1@yahoo.com.br>
Date2015-12-19 13:11 -0200
Message-ID<n53s25$7q6$1@speranza.aioe.org>
In reply to#29026
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web