Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda