Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
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>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can achieve this real quick with Jquery as follows:

$('input').change(function() {
  $('textarea').val('');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<input type="text">
<br/><br/>
<textarea>AAA</textarea>

You can replace .change with .keyup if you want the textarea value to reset immediately input is typed on.

input event triggers:
.change: Fires the moment the value of input is changed or clicked out of.
.keyup: Fires when a key is released on input.
.keydown: Fires when a key is pressed down on input.

about 4 years ago · Juan Pablo Isaza Report

0

Modify your HTML code as follows:

    <!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" id="inputField1" onInput="document.getElementById('textarea1').innerHTML = '';">
    <TEXTAREA id="textarea1" >aaa</TEXTAREA>


</BODY>
</HTML>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!