jQuery Disable Inputs version 1.4, 1.5 & 1.6

By Sam Deering

This is how you can disable input fields using jQuery. Note that in old versions of jQuery this can be done in different ways.

jQuery 1.6.x

Nowdays, to change the disabled property you should use the .prop() function.

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

jQuery 1.5.x and below

The .prop() function doesn’t exist, but .attr() does similar.

Set the disabled attribute:


To enable again:


In any version of jQuery

You can always rely on the actual DOM object and is probably a little faster than the other two options if you are only dealing with one element:

// assuming an event handler thus 'this'
this.disabled = true;

The advantage to using the .prop() or .attr() methods is that you can set the property for a bunch of selected items.

Free Guide:

7 Habits of Successful CTOs

"What makes a great CTO?" Engineering skills? Business savvy? An innate tendency to channel a mythical creature (ahem, unicorn)? All of the above? Discover the top traits of the most successful CTOs in this free guide.

No Reader comments

Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.