Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
How can I show page elements by clicking on button?

First I'll show my code

const mainButton = document.getElementById("start__button").addEventListener("click", function(event){
    event.target.parentNode.removeChild(event.target);
});

By clicking button, I want it to disappear and then appear new elements on page like navbar etc. The problem is I can't handle it at this point and I need some help :P

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

As indicated by the tags on your posts, you are using jQuery. So, try the following:

First, add the display: none style to all elements that should be hidden at the beginning. You can for convenience use a hidden class.

.hidden {
  display: none;
}

Then, add an onclick event to the button that hides the button and reveals all previously hidden elements.

$("start__button").on("click", function() {
  $(this).hide();
  $(".hidden").show();
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

const mainButton = document.getElementById("start__button").addEventListener("click", function(event){
        document.getElementById("navbar").classList.toggle("hidden");
    });
.hidden{
  display:none;
}
<navbar id="navbar">My navbar body....</navbar>
<button id="start__button">My Button</button>

This might help you
By the classList.toggle() function, you can toggle the class of the navbar or any other html element on clicking the button and after that using simple css, you can not only hide or show the element but also do other changes
Removing the whole element from the document and then again adding it by element.innerHTML = "..." is not recommended Thanks.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can group all of the content you want to show after click in a wrapper element.

const mainButton = document.getElementById("start__button");

mainButton.addEventListener("click", function(event){
    this.remove();
    document.querySelector('main').classList.remove('hidden')
});
.hidden {
  display: none;
}

main > * {
  padding: 1rem;
}

nav, footer {
  background: black;
  color: #fff;
}
<button id="start__button">start</button>
<main class="hidden">
  <nav>Navigation</nav>
  <section>Content</section>
  <footer>Footer</footer>
</main>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda