Answers for "how to get valu by id in js"

5

javascript get input value by id

<!--
This is example is with a number...
But you can do it with whatever input type you want
-->
<input type="number" name="numberInput" id="numberInput" max="20" min="1" step="1">
<button type="button" onclick="myFunction()">sumbit</button>

<script>
  function myFunction() {
    let tokenAmount = document.getElementById("numberInput").value;
    return // whatever you want to do with it
  }
</script>
Posted by: Guest on September-15-2021
2

how to get an element by id in javascript

document.getElementById("IdGoesHere");
Posted by: Guest on December-04-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language