www.webdeveloper.com
Results 1 to 2 of 2

Thread: trying to Learn document.getElementById

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Location
    Houston, TX
    Posts
    4

    Unhappy trying to Learn document.getElementById

    Hello,

    Ive recently set out to learn Javascript and all around i'm enjoying myself. I have a fairly good understanding of HTML and im looking to add JavaScript to the knowledgebase. I find my best means of learning is by trying to create pages, mostly at random and work with the various Javascript commands. However, this one is tripping me up. Accourding to the tutorials i've been reading it would seem this chunk of code should work... However it does not work as intended. Optimally there will be a function to give me the variable for streama but for the sake of troubleshooting i simplified it. Here is the output im getting....

    Watch live video from No Stream on www.twitch.tv
    theerebus

    The intended output is obviously

    Watch live video from the erebus on www.twitch.tv
    theerebus


    Code:
    <html>
    <body>
    
    <script>
    var streama = "theerebus";
    document.getElementById("stream1").href="http://www.twitch.tv/";
    document.getElementById("s").innerHTML="Watch live video from " + streama + " on www.twitch.tv";
    </script>
    
    <a href="http://www.twitch.tv/Nostream" class="trk" id="s" style="padding:2px 0px 4px; display:block; width:345px; font-weight:normal; font-size:10px; text-decoration:underline; text-align:center;">Watch live video from No Stream on www.twitch.tv</a>
    
    <script>
    document.write(streama);
    </script>
    
    </body>
    </html>

  2. #2
    Join Date
    Jul 2011
    Posts
    131
    document.getElementById("stream1").href="http://www.twitch.tv/";
    I don't see the element with id "stream1"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles