1

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.

  • This is actually a lot simpler with vanilla JavaScript. `element.disabled = true` –  Feb 22 '16 at 04:58
  • 6
    Possible duplicate of [Disable/enable an input with jQuery?](http://stackoverflow.com/questions/1414365/disable-enable-an-input-with-jquery) – Rino Raj Feb 22 '16 at 04:58

2 Answers2

2

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.

techdreams
  • 4,537
  • 7
  • 38
  • 54
0

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');
Bhushan Kawadkar
  • 27,451
  • 5
  • 33
  • 55