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

174
Views
Replacing text in an input box of a webpage

I wanted to replace a particular text "Dog" in an input box of a webpage to the text "Cat". I am new to jaavascript, so please pardon me for asking this question if I happen to break any forum rules. Thank you in advance. Vicky.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can get an element by it's id and then change it's value

document.getElementById("nameofid").value = "Cat";

about 4 years ago · Juan Pablo Isaza Report

0

you can use replace() function fot that.

const ta = document.querySelector("textarea");

const str = ta.value.replace("dog","cat");
ta.value = str
console.log(ta.value,"change to" ,str)
<textarea>a little dog.</textarea>

about 4 years ago · Juan Pablo Isaza Report

0

<html>
<body>
<h2>Change input box to Cat</h2>
<div id="inputBoxId">Dog</div>
<script>
 document.getElementById("inputBoxId").innerHTML = "Cat";
</script>
</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!