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

197
Views
Mostrar un div cuando se hace clic en el botón Javascript

Mi objetivo es mostrar un div con un mensaje exitoso cuando se hace clic en el botón Guardar. Desafortunadamente, todo lo que logré hacer fue mostrar este mensaje cada vez que se carga la página.

Aquí está mi código:

 <div id="fadeDiv"> <p>Content saved !</p> </div> $(document).ready(function () { $('#fadeDiv').fadeIn(1000); setTimeout(function () { $('#fadeDiv').fadeOut(1000); }, 1000); });

traté de hacer

 $('#saveBtn").click(...);

pero cuando hago clic en el botón, la página se vuelve a cargar incluso si no tengo un Response.Redirect(), por lo que mi div no se muestra.

Gracias por tu ayuda

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

0

Esta solución oculta el botón al principio.

 $("#saveBtn").click(function () { $('#fadeDiv').fadeIn(1000); setTimeout(function () { $('#fadeDiv').fadeOut(1000); }, 1000); });
 <div id="fadeDiv" style="display:none"> <p>Content saved !</p> </div> <button id="saveBtn"> Save! </button>

about 4 years ago · Juan Pablo Isaza Report

0

Consulte el siguiente enlace e intente con el suyo propio.

haga clic aquí

y avísame si quieres ayuda.

about 4 years ago · Juan Pablo Isaza Report

0

Ahí está la solución a su problema 1.Aquí está nuestro html

 <div id="fadeDiv"> <p>Content saved !</p> </div> <button id="saveBtn">Show</button>

2. Código Jquery

 $(document).ready(function(){ $("#fadeDiv").hide(); $("#saveBtn").click(function(){ $("#fadeDiv").show(); }); });

Explicación de la solución del problema. 1. La estructura html es la misma que la tuya, la solución está en el código jquery.

R. Esta línea $("#fadeDiv").hide(); oculta el div cuando llegamos por primera vez a nuestra página.

B. Y este código se ejecutará cuando hagamos clic en el botón Guardar
$("#saveBtn").click(función(){

});.

C.lo último, esta línea $("#fadeDiv").show(); mostrará el div oculto.

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!