0
Clearing the textarea on escape?
https://code.sololearn.com/WhH3Q09RHeQj/#js So I need this textarea to be cleared when escape is pressed, but only if the textarea is focused/active. Otherwise, It should alert the user that he/she must focus the textarea before they can clear it. Can somebody help me? I know how to clear it with escape, the problem is I need it to clear ONLY if the textarea is focused/active.
5 odpowiedzi
+ 3
Try it. It works
+ 1
change to
document.getElementById("TextArea" ).addEventListener( "keydown", Clear );
0
That's what it was initially Calviղ
I changed it to body while experimenting and I guess I saved it by accident
either way, it doesn't do exactly what I wanted it to
I tried hasFocus but I couldn't get it to work :(
0
Calviղ Check it out. I got it to do what I wanted.
https://code.sololearn.com/WhH3Q09RHeQj/?ref=app
0
Calviղ Check it out. I got it to do what I wanted.
https://code.sololearn.com/WhH3Q09RHeQj/?ref=app