Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript DOM -document.getElementById( ) Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 95
    Comment on it

    This method is used to get the elements after given specified id. Using this method we can get value from the input text field. But before to get value from input field , we need to define id for the input field.
    Syntax:

    document.getElementById("name") ;
    
    Example :
    Javascript Code :

    fun multiply()
    var a = document.getElementById("mul") ;
    alert("Result is :"+a*a*a);
    }
    

    Html Code :

    Enter Number :
    <form>
    <input type = "text" id = "mul" name = "number"/>
    <input type = "button"  value = "Click to see multiplication" onclick = "multiply()" />
    </form>
    

    Output :

    Result is 8 // If you pass the value " 2 " in input field
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

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