jquery Simple code to make form elements unavailable

  • 2021-07-02 22:53:42
  • OfStack

This section shows you how to set a form element to an unavailable state in 1 with simple example code.

The code example is as follows:


<!DOCTYPE html> 
<html> 
<head> 
<meta charset=" utf-8"> 
<meta name="author" content="https://www.ofstack.com/" /> 
<title> Script House </title> 
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script> 
<script type="text/javascript"> 
$(function(){ 
 $("#webname").prop("disabled","disabled"); 
 $("#bt").prop("disabled","disabled"); 
}) 
</script> 
</head> 
<body> 
 Website name :<input type="text" id="webname"/><br/> 
 Script House <input type="button" value=" View effect " id="bt"/> 
</body> 
</html>

The above code sets the disabled attribute of the form element through the prop () function.


Related articles: