We often need form data on the same page to send the data through AJAX. So in this example we will learn how to get value by class name Javascript
<!DOCTYPE html>
<html>
<body>
<input type='text' id=“hid_id” class='hid_id' value='1' />
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
var id = document.getElementsByClassName("hid_id");
if (id.length > 0) {
alert (id[0].value);
}
}
</script>
</body>
</html>