Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to get HTML structure using document.getElementById

    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 488
    Comment on it

    Hello Readers!

    In almost every web application their will be a need of javascript function "document.getElementById" , lets understand this how it work.

    Say suppose We have this HTML structure

    <div id="scores" style="display:none;">
            <ul id="scoreboard">

    We want to Show the updated Score in the ul tag of id="scoreboard" then how we will do this. Here's comes the concept of document.getElementById .

    var score = document.getElementById("scoreboard")

    Above code will save the HTML structure of id="scoreboard" in score variable.

    Now we can easily show User's score with the help of javascript function innerhtml. Here's the Code.

    var score = document.getElementById("scoreboard").innerHTML("User's Score").

    Similarly we can call the HTML structure using javascript function "document.getElementByClass".

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: