getElementById

Discussion in 'Javascript' started by bot-tak, Aug 2, 2003.

  1. bot-tak

    bot-tak Guest

    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
    bot-tak, Aug 2, 2003
    #1
    1. Advertising

  2. bot-tak wrote:

    > 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>


    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
    David Dorward, Aug 2, 2003
    #2
    1. Advertising

  3. bot-tak

    Evertjan. Guest

    bot-tak wrote on 02 aug 2003 in comp.lang.javascript:
    > 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>


    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").innerHTML);
    </script>
    </body>
    </html>





    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gilles T.
    Replies:
    8
    Views:
    2,070
    Alessandro Zifiglio
    Jan 5, 2004
  2. jm
    Replies:
    1
    Views:
    822
  3. Paul
    Replies:
    8
    Views:
    3,285
  4. Franck
    Replies:
    3
    Views:
    2,364
    Eliyahu Goldin
    Aug 25, 2005
  5. Ferret Face
    Replies:
    3
    Views:
    29,830
    Ferret Face
    Oct 4, 2005
Loading...

Share This Page