document.all vs. document.getElementById

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vin21
    New Member
    • Sep 2007
    • 2

    #1

    document.all vs. document.getElementById

    what is the difference b/w document.all() and document.getEle mentById()
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by vin21
    what is the difference b/w document.all() and document.getEle mentById()
    You should ask your Java questions in the Java Forum section, not the Java
    Articles section. I'll move your question to the Java Forum section.

    kind regards,

    Jos

    Comment

    • sumittyagi
      Recognized Expert New Member
      • Mar 2007
      • 202

      #3
      Originally posted by vin21
      what is the difference b/w document.all() and document.getEle mentById()
      This question is of javascript, you should ask javascript questions in javascript forum, not in java forum. You will be guided there better.

      document.all() is a non-standard way of accessing DOM elements. It was originally started by IE. Other browsers either depricated it or don't support it. document.all gives you access to all the elements on your element.

      On the other hand document.getEle mentById is a standard way of accessing the elements on the document. Each element have a unique id on the document which can be defined by id attribute of that element.

      So if you have <div id="abc"></div>

      and you do document.getEle mentById("abc") ; then you will have access to that div.
      But remember never give same ids to two different elements, else you could have unexpected results.

      Comment

      • prometheuzz
        Recognized Expert New Member
        • Apr 2007
        • 197

        #4
        Originally posted by sumittyagi
        This question is of javascript, you should ask javascript questions in javascript forum, not in java forum. You will be guided there better.
        ...
        Moved it to the JavaScript forum.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          hi ...

          please ... always use a good thread title

          kind regards

          Comment

          Working...