SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot maileen's Avatar
    Join Date
    Apr 2006
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question i'm tired or blind : stupid javascript test

    Hi,

    I try to understand something regarding getelementbyid.

    here is a stupid test of Javascript.

    <html>
    <head></head>
    <body>
    <style>
    .maindiv
    {
    background-color : #BBBBBB;
    /*width : 200px;*/
    /*height : 200px;*/
    }
    .childdiv
    {
    background-color : #DD80DD;

    }
    </style>

    <img src='A_des_img/node.gif' style='vertical-align:middle;background-color:#EEAAFF;'>
    <b onclick='alert(document.getElementByID("id_maindiv").id);' id='b_id' style='vertical-align : middle;background-color:#EEAAFF;'>my 1st div</b><br>
    </img>

    <div class='maindiv' id='id_maindiv'>
    </div>


    </body>
    </html>

    when i click on <b> tag, i should display an alert message with "id_maindiv" as text.
    however, nothing is displayed, why ?
    Maybe i'm very tired and i do not have well opened eyes, but i would like to understand...

    thanks a lot,

    M.

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    JavaScript is case sensitive. You mean "getElementById", not "getElementByID".
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Zealot maileen's Avatar
    Join Date
    Apr 2006
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry that's true... i was really tired or blind.

    thx.
    M.

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Firebug

    If you use Firefox with the Firebug add-on, finding errors like this becomes simple. It would report something like:

    document.getElementbyID has no properties, which might point you at the typo.

    Dave


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •