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

145
Views
Interchnage the children of two divs using a button

My document structure is:

<div id="mainWindow">
    <div id="subele1"></div>
</div>

<div id="subWindow">
    <div id="subele2"></div>
</div>

I want to create a button so that the children subele1 and subele2 are interchanged every time the button is clicked.

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

0

UPD

function handleButtonClicked() {
  const mainElement = document.getElementById('subele1')
  const subElement = document.getElementById('subele2')

  const mainElementValue = mainElement.innerHTML
  mainElement.innerHTML = subElement.innerHTML
  subElement.innerHTML = mainElementValue
}
<div id="mainWindow">
  <div id="subele1">main Window!</div>
</div>

<div id="subWindow">
  <div id="subele2">sub Window?</div>
</div>

<button id='main' onclick={handleButtonClicked()}>switch</button>

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!