user5523947
user5523947

Reputation:

How to disable an input with jQuery

I am trying to do it like this which has worked for me before but is not working for me now.

$("input").attr('disabled','disabled');

Can anyone tel me why it is not working while it has worked for me in previous projects.

Upvotes: 1

Views: 76

Answers (2)

Bhushan Kawadkar
Bhushan Kawadkar

Reputation: 28513

You must have upgraded to newer version of jQuery which is greater than 1.5. For jQuery greater than 1.5, attr will not work but need to use prop as shown below.

$("input").prop('disabled','disabled');

Upvotes: 0

techdreams
techdreams

Reputation: 5583

What you are doing is old style was applicable for Jquery 1.5 and below. For version 1.6 and above you need to write this

$("input").prop('disabled', true);

Hope it helps.

Upvotes: 2

Related Questions