Как отключить или включить ввод с помощью jQuery в JavaScript

Чтобы отключить или включить ввод с помощью jQuery в JavaScript, вы можете использовать следующие методы:

  1. Метод prop():

    // Disable the input
    $('#yourInputId').prop('disabled', true);
    // Enable the input
    $('#yourInputId').prop('disabled', false);
  2. Метод attr():

    // Disable the input
    $('#yourInputId').attr('disabled', true);
    // Enable the input
    $('#yourInputId').attr('disabled', false);
  3. Метод removeAttr():

    // Disable the input
    $('#yourInputId').removeAttr('enabled').attr('disabled', 'disabled');
    // Enable the input
    $('#yourInputId').removeAttr('disabled').attr('enabled', 'enabled');
  4. Метод prop()с функцией:

    // Disable the input
    $('#yourInputId').prop('disabled', function() {
     return true;
    });
    // Enable the input
    $('#yourInputId').prop('disabled', function() {
     return false;
    });