Darkloki
Darkloki

Reputation: 686

Disable ALL dropdownlist with jquery

I am using jQuery to disable all inputs until the user performs some action.

$('input[type=text]').attr('readonly', true);
$('input[type=select]').attr('disabled', true);

This works fine for the textboxes but doesn't affect the dropdown list. Is it the type or something else? Thank you in advance.

Upvotes: 0

Views: 952

Answers (1)

Andrei
Andrei

Reputation: 56688

Use prop() instead of attr() for this. Besides select is not an input but a separate tag:

$('select').prop('disabled', true);

Also you can simply use :input selector to reference all inputs in one go. This will cover both input and select:

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

Upvotes: 2

Related Questions