prop()
methodYou can use the jQuery prop()
method in combination with the :input
selector to disable all <input>
, <textarea>
, <select>
and <button>
elements inside an HTML form dynamically using jQuery. The prop()
method require jQuery 1.6 and above.
Let's check out an example to understand how this method basically works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Disable All Form Elements</title>
<style>
label {
display: block;
margin-bottom: 5px;
}
label, input, textarea, select {
margin-bottom: 10px;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$("#myForm :input").prop("disabled", true);
});
</script>
</head>
<body>
<form id="myForm">
<label>Name:</label>
<input type="text">
<label>Address:</label>
<textarea></textarea>
<label>Country:</label>
<select>
<option>select</option>
</select>
<br>
<button type="button">Submit</button>
<button type="button">Reset</button>
</form>
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How To Set up SSH Keys on a Linux Server
SSH or Secure Shell is network protocol...Laravel 5.5 get current login user details using Auth
Today, we are share with youu how to get...How to Get the Class Name of an Object in JavaScript
Use the name Property You can use the...Generate new CSRF token in LARAVEL by using Ajax
Laravel protects all post routes form CS...Laravel 8 Load More Data on Page Scroll using Jquery Ajax
You have already known about Twitter and...