HTML CSS Javascript jQuery AJAX PHP Java MORE
Need a Website Or Web Application.Contact : +91 9437911966 (Whatsapp) Note: Paid Service

How to get value by class name Javascript

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>

Run it yourself