Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML / Javascript: On Click Enable/UnDisable Input Fields?

I have the following HTML input boxes:

<form>
<input type="text" name="1" id="1" disabled>
<input type="text" name="2" id="2" disabled>
<input type="text" name="3" id="3" disabled>
<input type="text" name="4" id="4" disabled>
<input type="submit" name="submit" value="submit>
</form>

Next I am trying to use javascript to undisable all my input boxes upon a user clicking my div.

JavaScript:

<script>
    $('#edit').click(function(){
        $('input[]').prop('disabled', false);
});
</script>

Can someone please show me where I am going wrong, thanks

like image 589
Mark harris Avatar asked Mar 16 '26 03:03

Mark harris


1 Answers

The error is the selector, try:

 $('input').prop('disabled', false);
like image 74
josedefreitasc Avatar answered Mar 19 '26 02:03

josedefreitasc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!