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

95
Views
¿Cómo arreglo mi SideBar para que se abra y se cierre?

Estoy tratando de hacer que un SideNav se abra y se cierre después de presionar un botón. Sin embargo, solo puedo hacer que se cierre. Cuando paso la función sideNave() a button.addEventListener("click", ... ) no pasa nada. Agradeceria mucho su ayuda! Mi código a continuación:

 const left = document.querySelector("left"); const right = document.querySelector("right"); const button = document.querySelector("button"); button.addEventListener("click", close); const x = true; function close() { document.getElementById("left").style.width = "0"; document.getElementById("right").style.width = "100%"; x = false; } function open() { document.getElementById("left").style.width = "15%"; document.getElementById("right").style.width = "85%"; x = true; } function sideNav() { if (x = true) { w3_close(); } else { open(); } }
 <!DOCTYPE html> <html> <head> <title>WebPage</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="webPage.css"> <meta charset="utf-8"> <script src="https://kit.fontawesome.com/62ea397d3a.js" crossorigin="annonymous"></script> </head> <body> <div class="header"></div> <div id="left"> <button class="button">Click Me!</button> </div> <div id="right"> <p></p> </div> </body> </html>

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

0

Haga clic en el símbolo ☰ para abrir la barra lateral (superpone parte del contenido de la página). function w3_open () { document.getElementById("mySidebar").style.display = "block"; } function w3_close () {

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!