+ 1
How can we take the html input to JavaScript and then use it ?
I am trying to construct the basic calculator page so I need the input numbers to taken by JavaScript and then print the result in other html element. Please help
1 Answer
+ 5
Get the element reference with such methods as .getElementById() and access its 'value' attribute (read/write access):
<input type="text" id="myInput">
<script>
var inp = document.getElementById('myInput');
alert(inp.value);
</script>