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

307
Vistas
how to hide one div and display another on button click event in MVC

Here is my jquery and div i want to hide tblMain and make tblmainalt visible

$("btnUpdate").click(function() {
  alert("button");
  $("tblMain").hide();
  $("tblMainAlt").show();
});
<div id="tblMainAlt" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">
<div id="tblMain" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

This is because you have used wrong selector. Either you have to use ID or CLASS selector. As seeing you HTML you please replace your jQuery with mine and it will worked.

$("#btnUpdate").click(function() {
  alert("button"); // Remove this line if it worked
  $("#tblMain").hide();
  $("#tblMainAlt").show();
});
over 4 years ago · Santiago Trujillo Denunciar

0

set display: none in style in tblMainAlt because loaded first time a page so hide a div.

i have add sample code so you can try it.

JQuery:-

$("#btnUpdate").click(function () {
                alert("button");
                $("#tblMain").hide();
                $("#tblMainAlt").show();
            });

 <div id="tblMainAlt" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;display: none;">

<div id="tblMain" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">
over 4 years ago · Santiago Trujillo 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