getElementById

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bot-tak

    getElementById

    Hi
    it shouldn't be not so difficult
    everytime, in each browser i see "nothing".
    where is the element?

    <html>
    <head>
    <script type="text/javascript">
    alert(document. getElementById( "cool"));
    </script>
    </head>
    <body>
    <p id="cool">this is content</p>
    </body>
    </html>

    vassili


  • David Dorward

    #2
    Re: getElementById

    bot-tak wrote:
    [color=blue]
    > it shouldn't be not so difficult everytime, in each browser i see
    > "nothing". where is the element?
    > <html><head>
    > <script type="text/javascript">
    > alert(document. getElementById( "cool"));
    > </script>
    > </head><body><p id="cool">this is content</p></body></html>[/color]

    At the time the script it run, it doesn't exist.

    window.onload = function(){
    alert(document. getElementById( "cool"));
    }

    --
    David Dorward http://david.us-lot.org/
    Which is stupider: Pop-up ads claiming they'll stop spam, or spam claiming
    it'll stop pop-up ads? -- Dork Tower

    Comment

    • Evertjan.

      #3
      Re: getElementById

      bot-tak wrote on 02 aug 2003 in comp.lang.javas cript:[color=blue]
      > it shouldn't be not so difficult
      > everytime, in each browser i see "nothing".
      > where is the element?
      >
      > <html>
      > <head>
      > <script type="text/javascript">
      > alert(document. getElementById( "cool"));
      > </script>
      > </head>
      > <body>
      > <p id="cool">this is content</p>
      > </body>
      > </html>[/color]

      try this, vassili:


      <html>
      <head>
      </head>
      <body>
      <p id="cool">this is content</p>

      <script type="text/javascript">
      alert(document. getElementById( "cool"));
      alert(document. getElementById( "cool").innerHT ML);
      </script>
      </body>
      </html>





      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      Working...