0
var textoUser = $("#txtFieldUser");
var textoGanhador = $("txtFieldGanhador");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "Pedra";
} else if(computerChoice <= 0.67) {
computerChoice = "Papel";
} else {
computerChoice = "Tesoura";
}
console.log("Computer: " + computerChoice);
var compare = function (choice1, choice2) {
if (choice1 === choice2)
return ("O resultado é um empate!");
else if (choice1 === "pedra") {
if (choice2 === "tesoura")
return ("pedra vence");
else {
return ("papel vence");
}
}
else if (choice1 === "papel") {
if (choice2 === "pedra")
return "papel vence";
else {
return "tesoura vence";
}
}
else if (choice1 === "tesoura") {
if (choice2 === "pedra")
return "pedra vence";
else {
return "tesoura vence";
}
}
};
compare(textoUser, computerChoice);
$('#txtFieldComputer').ready(function() {
$('#txtFieldComputer').val(computerChoice);
});
You just create the
input
and place the attributeid
with the valuetxtFieldComputer
being like this:<input type="text" id="txtFieldComputer" />
– NoobSaibot
The problem is in
ready
that is too much. the$('#txtFieldComputer').val(computerChoice);
alone does what you want. Theready
is for document, when ready, to be used like this$( document ).ready(function() {
– Isac