Mastering the document.getElementById() Method in JavaScript
☰Fullscreen
Table of Content:
document.getElementById() method - Javascript
The document.getElementById() method returns the element of specified id.
html code
<form> Enter No:<input type="text" id="number" name="number"/><br/> <input type="button" value="cube" onclick="getcube()"/> </form>
Javascript Code
<script type="text/javascript"> function getcube(){ var number=document.getElementById("number").value; alert(number*number*number); } </script>
Live Preview

No Questions Data Available.
- Assignment 1: How do I replace div with textarea when I click button (including content)?