Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Newbie: how do I analyse DOM Objects?

Newbie: how do I analyse DOM Objects?

Scheduled Pinned Locked Moved JavaScript
questionjavascripthtmlhelptutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    enginestar
    wrote on last edited by
    #1

    I'm learning Javascript. I'm following some example code on a video. I've got stuck trying to change some existing code. The first step I thought would be to identify the object I'm dealing with. What's the best way of doing this? I've tried console.dir(document) - but that bring back *everything*. I know I can drill down further... but I thought I'd ask here before trying anything else. Thanks.

    L 1 Reply Last reply
    0
    • E enginestar

      I'm learning Javascript. I'm following some example code on a video. I've got stuck trying to change some existing code. The first step I thought would be to identify the object I'm dealing with. What's the best way of doing this? I've tried console.dir(document) - but that bring back *everything*. I know I can drill down further... but I thought I'd ask here before trying anything else. Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I am not quite certain what you are asking, but take a look at XML DOM Tutorial[^].

      E 1 Reply Last reply
      0
      • L Lost User

        I am not quite certain what you are asking, but take a look at XML DOM Tutorial[^].

        E Offline
        E Offline
        enginestar
        wrote on last edited by
        #3

        Richard, thanks for the reply. I was stuck on a problem. I couldn't see what I was doing wrong. I had an ID and in my Javascript I had:

        const CIRCLE = document.querySelector('circle');

        I'd spent sooo much time trying to figure out what I had done wrong. So... in the end I thought there must be a way to find all objects/elements on a page? I had tried

        document.querySelectorAll

        but wasn't sure where to type this (complete newbie... learning JS). I found the error: I was missing a # But... I still have my question... how could I drill down and find a specific object that I was having trouble getting the exact details of? Hope that makes sense.

        L C 2 Replies Last reply
        0
        • E enginestar

          Richard, thanks for the reply. I was stuck on a problem. I couldn't see what I was doing wrong. I had an ID and in my Javascript I had:

          const CIRCLE = document.querySelector('circle');

          I'd spent sooo much time trying to figure out what I had done wrong. So... in the end I thought there must be a way to find all objects/elements on a page? I had tried

          document.querySelectorAll

          but wasn't sure where to type this (complete newbie... learning JS). I found the error: I was missing a # But... I still have my question... how could I drill down and find a specific object that I was having trouble getting the exact details of? Hope that makes sense.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry, I am still not sure what you are trying to do, but see document.querySelectorAll() - Web APIs | MDN[^].

          E 1 Reply Last reply
          0
          • L Lost User

            Sorry, I am still not sure what you are trying to do, but see document.querySelectorAll() - Web APIs | MDN[^].

            E Offline
            E Offline
            enginestar
            wrote on last edited by
            #5

            i think it's just me. :) i freaked out after spending hours trying to find where i had gone wrong. so was looking for a way to find all items on a page and then i could dig down and get the exact text i would need to put in for accessing. thanks for all ur replies.

            L 1 Reply Last reply
            0
            • E enginestar

              i think it's just me. :) i freaked out after spending hours trying to find where i had gone wrong. so was looking for a way to find all items on a page and then i could dig down and get the exact text i would need to put in for accessing. thanks for all ur replies.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              enginestar wrote:

              thanks for all ur replies.

              Happy to help. BTW, using txtspk (ur) here is frowned upon.

              1 Reply Last reply
              0
              • E enginestar

                Richard, thanks for the reply. I was stuck on a problem. I couldn't see what I was doing wrong. I had an ID and in my Javascript I had:

                const CIRCLE = document.querySelector('circle');

                I'd spent sooo much time trying to figure out what I had done wrong. So... in the end I thought there must be a way to find all objects/elements on a page? I had tried

                document.querySelectorAll

                but wasn't sure where to type this (complete newbie... learning JS). I found the error: I was missing a # But... I still have my question... how could I drill down and find a specific object that I was having trouble getting the exact details of? Hope that makes sense.

                C Offline
                C Offline
                Christian7573
                wrote on last edited by
                #7

                If you want to access everything in the order it is stored in as HTML, use

                document.querySelector("html")

                to get the root html element of the document, and then use the .children array of any element to see what's inside it.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups