SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What did I do wrong this time?!

    Hi,
    In my javascript book, I have an exercise where I'm supposed to create a document with a couple of elements each of which have id attributes, then retrieve those elements and make changes to them. So, here's the code I tried to run...Firebug is telling me that "document.getElementbyID is not a function". What's wrong?

    Thanks,
    Jeff

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Create</title>

    </head>
    <body>
    <p id="para1">This is paragraph 1 </p>
    <p id="para2">This is paragraph 2 </p>

    <script type = "text/javascript" >
    var e1 = document.getElementByID("para1");
    var e2 = document.getElementByID("para2");
    e1.innerHTML = "New para1";
    e2.innerHTML = "New para2";

    </script>
    </body>
    </html

  2. #2
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You have used the wrong syntax. It should be:

    document.getElementById

    NOT

    document.getElementByID

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Allan. I made a similar mistake a few days ago with innerHTML! Hopefully now I'll remember how particular javascript is re. upper/lower case.

    I really appreciate you, and the others who continue to take the time to help me out --I would have already given up without this forum!


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
  •