Disabled HTML and Jquery property

2

Does anyone know why it is not disabled in jquery. That is, when I click the button. I want to click on the button (disabled = false)

                      

    $(document).ready(function(){

        $("#b2").click(function(){

       $("input").prop(disabled,false);

           });
    });
    </script>
</head>
<body>



    <input  disabled="true">

    <button id="b2">botao</button>

</body>

    
asked by anonymous 05.11.2017 / 18:28

2 answers

2

To change properties or attributes of an element with jQuery, in the syntax, the attribute name and the value should be enclosed in quotation marks:

$('elemento').prop('atributo', 'valor');

In the case of disabled , because it is a value Boolean , it can be outside the quotation marks:

$('elemento').prop('disabled', false);
    
05.11.2017 / 18:46
2

You need to use a String for the property name.

Mute

.prop(disabled, false);

for

.prop('disabled', false);

$(document).ready(function() {
  $("#b2").click(function() {
    $("input").prop('disabled', false);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputdisabled="true">

<button id="b2">botao</button>
    
05.11.2017 / 18:32