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

172
Views
Quiero hacer que un botón intercambie dos envoltorios div y sus elementos secundarios.

Estoy tratando de hacer que un botón cambie dos divs y sus elementos secundarios. Sus elementos secundarios incluyen un y con texto. Solo quiero hacer clic en el botón y hacer que todo el contenido intercambie lugares.

Aquí está el html y javascript.

 function switchTokens() { var obj1 = document.getElementById('from_token_select').value; var obj2 = document.getElementById('to_token_select').value; var temp = obj1; obj1 = obj2; obj2 = temp; // Save the swapped values to the input element. document.getElementById('from_token_select').value = obj1; document.getElementById('to_token_select').value = obj2; }
 <div class="token_select" id="from_token_select"> <img src="https://image-placeholder.com/images/actual-size/75x100.png" class="token_image" id="from_token_img" /> <span id="from_token_text">from_token_text</span> </div> <button onClick="switchTokens()" id="swap_token_address" class="fa-solid fa-arrows-up-down">switchTokens Btn</button> <div class="token_select" id="to_token_select"> <img src=https://image-placeholder.com/images/actual-size/88x31.png class="token_image" id="to_token_img" /> <span id="to_token_text">to_token_text</span> </div>

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

0

Según tengo entendido, ¿le gustaría intercambiar todo el contenido de los divs? Si ese es el caso, este JS hace el truco:

 function switchTokens() { var obj1 = document.getElementById('from_token_select').innerHTML; var obj2 = document.getElementById('to_token_select').innerHTML; // Save the swapped values to the input element. document.getElementById('from_token_select').innerHTML = obj2; document.getElementById('to_token_select').innerHTML = obj1; }
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!