maztt
maztt

Reputation: 12304

asp.net mvc jquery how to enable the button after disable

 $("#btn").attr("disabled", "disabled");

i have used the above line to disable the button how would i enable it .this is not working

 $("#btn").removeAttr("disabled");

Upvotes: 1

Views: 6824

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039508

The code you've shown definitely works:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
    <a href="#" onclick="$('#btn').attr('disabled', 'disabled')">Disable button</a><br/>
    <a href="#" onclick="$('#btn').removeAttr('disabled')">Enable button</a><br/>
    <input type="button" id="btn" value="Some Button" />
</body>
</html>

Upvotes: 1

David Hedlund
David Hedlund

Reputation: 129832

The jQuery attr-selector actually has an overload for this, where you can pass true/false for disabled specifically:

$('#btn').attr('disabled', true);
$('#btn').attr('disabled', false);

Upvotes: 0

Related Questions