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

156
Visualizações
Reach the parent element from the child

i have some elements that contain a couple of elements. I want when I click on the child element, the parent of the element disappears with all its nested elements (nested_parent and the nested_parent1 and the child) .

.parent{
    margin-top: 10px;
    width: 125px;
    height: 125px;
    background-color: red;
    display: flex;
    justify-content: center;
    align-items: center;
}
.nested_parent {
    width: 100px;
    height: 100px;
    background-color: aqua;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
}
.nested_parent1 {
    width: 75px;
    height: 75px;
    background-color: blueviolet;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
}
.child {
    width: 50px;
    height: 50px;
    background-color: beige;
    cursor: pointer;
}
<div class="parent">
        <span class="nested_parent">
            <span class="nested_parent1">
                <i class="child"></i>
            </span>
        </span>
    </div>
    <div class="parent">
        <span class="nested_parent">
            <span class="nested_parent1">
                <i class="child"></i>
            </span>
        </span>
    </div>
    <div class="parent">
        <span class="nested_parent">
            <span class="nested_parent1">
                <i class="child"></i>
            </span>
        </span>
    </div>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Add a click handler to the children:

$('i.child').click(function(){
  $(this).parent().parent().hide()
})

When you click a child, it will cause its grandparent to hide (.nested_parent), which automatically hides its descendants (.nested_parent1 and .child).

about 4 years ago · Juan Pablo Isaza 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