Dear Mates, Please click the ads to support us.
Tutorial

Toggle Disabled Attribute in Jquery

Kailash Singh Dec 06, 2022 2079 Views
Kailash Singh

Toggle Disabled Attribute in Jquery Share

Published Dec 06, 2022 by Kailash Singh 0 Comments 2079 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