Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to reset a value of a textarea if another input has value

I’m new to JS I have input and textarea I want to reset the textarea’s value, if input is changed

<!doctype html>
<HTML lang="en">
<HEAD>
<META charset="utf-8">
<META name="viewport" content="width=device-width, initial-scale=1">
<TITLE>Hello, world!</TITLE>
</HEAD>
<BODY>
<INPUT type="text">
<TEXTAREA>AAAA</TEXTAREA>
</BODY>
</HTML>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

first why you are typing in UPPERCASE, this is old html, in HTML5 you should write the tags in lowercase.
to reset the textarea inner text when the input’s value change, as I understand from your question you only have to add Event Listener

document.querySelector('input').addEventListener('change', function(){
  document.querySelector('textarea').innerText = "";
});

example

document.querySelector('input').addEventListener('input', function() {
  document.querySelector('textarea').innerText = "";
});
<input type="text" />
<textarea>textarea</textarea>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading