It is not understood if you want to use Jquery or "bare" Javascript; you are mixing the two alternatives.
In "bare" Javascript it would be:
function habilitar() {
document.getElementById('partyCode').disabled = false;
}
<input id="partyCode" placeholder="Party code" type="text" disabled>
<input type="button" id="uParty" value="Unirse a party" onclick="habilitar()">
With Jquery it would be like this:
$("#uParty").click( function() {
$("#partyCode").prop('disabled', false);
}
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="partyCode" placeholder="Party code" type="text" disabled>
<input type="button" id="uParty" value="Unirse a party" >
Of course, it is important that you understand what happens in each case ...
By the way, your original code simply walks if you get the function out of all that jquery initialization block
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input id="partyCode" placeholder="Party code" type="text" disabled>
<input onclick="uParty()" type="button" id="uParty" value="Unirse a party">
<script>
function uParty() {
document.getElementById('partyCode').disabled = false;
}
</script>
</body>
</html>
Your original code, what I was doing was, at the moment of being ready
the page, running a certain (anonymous) function which only declared a function uParty
(and remember that declaring a function in Javascript is like instantiate an object). But that function uParty
was declared / instantiated as a local object of the anonymous function (and it was not invoked or assigned or anything), so that when the anonymous function was finished, there were no traces of uParty
. You, on the other hand, wanted uParty
to be available in the global environment (that in Javascript hosted on the website corresponds to the object window
). Therefore, you could if you want to do this:
$(document).ready(function(){
window.uParty = function () {
document.getElementById('partyCode').disabled = false;
}
});
But it would be something twisted, and nothing necessary.