Чтобы отключить или включить ввод с помощью jQuery в JavaScript, вы можете использовать следующие методы:
-
Метод
prop():// Disable the input $('#yourInputId').prop('disabled', true); // Enable the input $('#yourInputId').prop('disabled', false); -
Метод
attr():// Disable the input $('#yourInputId').attr('disabled', true); // Enable the input $('#yourInputId').attr('disabled', false); -
Метод
removeAttr():// Disable the input $('#yourInputId').removeAttr('enabled').attr('disabled', 'disabled'); // Enable the input $('#yourInputId').removeAttr('disabled').attr('enabled', 'enabled'); -
Метод
prop()с функцией:// Disable the input $('#yourInputId').prop('disabled', function() { return true; }); // Enable the input $('#yourInputId').prop('disabled', function() { return false; });