$("#submitButton").attr("disabled", "disabled")



Description

This would modify the disabled attribute to the value "disabled" while clicking Submit button.

Syntax

Here is the simple syntax to use this method −

selector.attr("disabled","disabled");

Parameters

Here is the description of all the parameters used by this method −

  • disabled This is the CSS property of the matched element.

  • disabled This is the value to be set to the matched element.

Example

Following example would modify the disabled attribute to the value "disabled" while clicking Submit button.

Live Demo
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>		
      <script type = "text/javascript" language = "javascript">	 
         function disableSubmit(){
            $("#submitButton").attr("disabled", "disabled");
         }
      </script>
   </head>	
   
   <body>
      <div>
         <form name = "sampleForm">
            <input type = "text" id = "result1" title="The jQuery Example" value = "sample" ></input><br/><br/>
            <input type = "text" id = "result2" title="The jQuery Example" value = "sample" ></input> <br/><br/>
            <input type = "button" id = "submitButton" onclick="disableSubmit();" value = "submit"/>
         </form>
      </div>
   </body>	
</html>

This will produce following result −

jqueryexamples_attributes.htm
Advertisements