Forum Replies Created
-
AuthorPosts
-
April 9, 2017 at 1:01 am in reply to: 1.3.04 – Traversing the DOM – Differences between parentElement and parentNode #25438
John
ParticipantHi Zac,
I just reviewed the video again and it was good to reconsider the lesson for reinforcement.
this time I thought I would experiment with the example page for 1.3.3.2 by addressing elements within and then drilling down further. an example being ‘div’.
I if do this I get an array of 3 elements
div1 = document.getElementsByTagName ( ‘div’ );
and if I console.log the 2nd element out (console.log ( div1[1] ) 😉 I see: div id=”contact”>
but if I try to set view an element within this 2nd element I error.
ie: console.log (div1[1].getSelector( ‘p’ ) );
In fact, a clue that I am going wrong is that the auto complete text does not make suggestions. even if I console.log (div1……..)
Does anyone know what I am doing wrong?
Thanks,
John.
April 4, 2017 at 8:20 am in reply to: 1.3.04 – Traversing the DOM – Differences between parentElement and parentNode #25286John
ParticipantI’m also interested in this section. but for a different reason. Zac said to find a site and start traversing the DOM. So i chose the one linked at the bottom of the video DOM Enlightenment Site
it has alot of information in it and a table of contents with an id=”toc”.
So I used
content = document.querySelector( ‘#toc’ );Then I did this to get the number of children
contentChildrenEls = content.children
HTMLCollection[130]I then decided to get the first child with this
contentFirstChildNode = content.firstChildThat works fine but I wonder about how I make any sense of all of this. I mean firstly, how do I grab the second child? Next, how do I know there even is a second child? aside from the children property which tells me there are 130.
and what use is this to me anyway? I guess I’m looking at this from outside. If I was the web page developer I would know what my html structure looked like. is that fair to say? in which case I’d be traversing a DOM that I built.
Am I on the right track?
Thanks.
john.
-
AuthorPosts