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

189
Views
is it possible for me to click the button several times to change the text that shows?

im actually new to scripting and i am planning to do my own blog site (with my own touch) but it seems i've stumbled upon a roadblock..

the thing is, i wanted a button that changes the text that shows up on screen, and i have successfully did that by using a code that i borrowed from w3schools lol..

here is the code that i used: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_text

it swapped the text by clicking on a button.. now the question is, would i be able to change the swapped text with another text just by clicking on the same button again? cuz that's what i am initially going for.

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

0

You have to use else if statement continuously

function myFunction() {
 var x = document.getElementById("myDIV");
  if (x.innerHTML === "Hello") {
   x.innerHTML = "Swapped text!";
  } else if (x.innerHTML === "Swapped text"){
   x.innerHTML = "Some another text...";
  } else if (x.innerHTML === "Some another text..."){
   x.innerHTML = "Again some text";
}
}

Like this you have to continue, if you have multiple texts

I hope you understood and am a beginner in these. Thank You

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!