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

187
Vistas
jQuery - hidden class is not being displayed with fadeIn

I have a hidden class fadeThis, which does not appear when I hover over the button. Perhaps it is clashing with another class/div?

What I'm essentially trying to do is create a red fade in over the grey box, when the cursor hovers over the button, and then when the cursor leaves the box(not the button), I want it to return back to it's original state.

I've also added the CSS to help demonstrate

HTML

    <div class="imageOne">

        <div class="onClickThis"> <!-- hidden by default-->
            <h2 class="fadeThis">Whatever the text needs to be</h2> <!-- hidden by default-->
        </div>
        <div class="centerButton">
            <button class="btn">View More</button>
        </div>
    </div>

CSS

.imageOne{
    height: 300px;
    width: 400px;
    background-color: grey;
}

.centerButton{
    display: flex;
    justify-content:center;
    padding-top:150px;
}

.btn{
    height: 30px;
    width:170px;

}

.onClickThis{
    height: 300px;
    width: 400px;
    background-color: tomato;

}

JavaScript

$(document).ready(function () {
    $(".onClickThis").hide();
    $(".fadeThis").hide();
    $(".btn").hover(function () {
        $(".imageOne").fadeIn("slow", function () {
            $(this).addClass("fadeThis onClickThis");
            $(".btn").remove();
        });
        $(".onClickThis").mouseleave(function () {
            $(this).removeClass("fadeThis onClickThis");

        });
    });

});
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I don't understand exactly what you are looking for. Maybe you could provide more details.

Here is a demo started from your code with some changes added.

$(document).ready(function () {
    $(".onClickThis, .fadeThis").hide();
  
    $(".btn").hover(function () {
        $(".imageOne").fadeIn("slow", function () {
           $(".onClickThis, .fadeThis").fadeIn( 250 );
           $(".btn").fadeOut();
        });
    });
});
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  
<div class="imageOne">
  <div class="onClickThis"> <!-- hidden by default-->
      <h2 class="fadeThis">Whatever the text needs to be</h2> <!-- hidden by default-->
  </div>
  <div class="centerButton">
      <button class="btn">View More</button>
  </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</body>
</html>

about 4 years ago · Santiago Gelvez 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