jQuery - Function . prop()

Asked

Viewed 165 times

1

I have a input which is disabled by default, but I wanted to enable it in the page loading through jQuery, but it is not working.

Code of input:

<input type="text" title="Número" name="billing[street][2]" id="billing:street2" class="input-text required-entry" value="" autocomplete="off" disabled="">

I tried the code below but did not succeed:

$j(document).ready(function(){
    $j('#billing:street2').prop('disabled',false);
})

1 answer

2


When you need to use special characters in your seletor, it is necessary to use \\(two backslashes), so that the character is treated as text and not as a regular expression. Another error contained in your code is the character j after the $.

$(document).ready(function(){
    $("#billing\\:street2").prop('disabled',false);
});
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<input type="text" title="Número" name="billing[street][2]" id="billing:street2" class="input-text required-entry" value="" autocomplete="off" disabled="">

Learn more about seletores here.

  • It worked! Thank you very much for the help and attention! An observation: the character $j it wouldn’t be a mistake, because I use $j.noConflict(); so that I don’t have conflicts with other libraries. But anyway, thank you very much for the help!

  • Oh yes, I understand...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.