Toggle Disabled Attribute in Jquery

Kailash Singh

Toggle Disabled Attribute in Jquery

Published Dec 06,2022 by Kailash Singh

0 Comment     657 Views    


In this tutorial, we are going to create an HTML input box that is Toggle Disabled and Enable by a single button in Jquery.

 

Step1: Create HTML

<html >
	<head>
   		<title>ELevenstech Web Tutorials</title>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
   </head>
	<body>
      <div>

        <input type="text" id="tt1" /><br />
        <button type="button" id="btn1">Disable</button>

      </div>
	</body>
</html>

 

Step2: Create jQuery.

<script>
	$(document).ready(function(){
      $('#btn1').click(function(){
        	$('#tt1').prop('disabled', function(i, v) { return !v; });
      });
    });
</script>

 


Comments ( 0 )