3
Good evening. I wanted to remove the disabled attribute from a tag when a certain condition is met, but I couldn’t find any idea how to do that. Below the HTML:
Escreva aqui: <input type="text" id="text1" autofocus><br> <!--input livre-->
Depois aqui: <input type="text" id="text2" disabled> <!--deveria ficar livre depois que enviar o valor do input#text1-->
Now the Javascript:
const t = document.querySelector("#text1")
t.addEventListener('keyup', function(e){
var key = e.which || e.keyCode;
if (key == 13) { //quando a tecla enter é apertada a função abaixo acontece
//aqui deveria entrar a função de tirar o disabled do input#text2
}});
If anyone can please help me.
I’ve tried it and it hasn’t worked yet.
– Guilherme Ziivo
He’s going into the
if(key == 13)
? If there’s a way you can test and tell us.– leofalmeida
Yes, you are, just like you said.
– Guilherme Ziivo
Try to give a
console.log(document.getElementById("text2"))
to see if he’s getting the element.– leofalmeida