Problem with effect on multiple Lis

Asked

Viewed 23 times

1

I’m 4 li, 2 of them are appearing on the site, and other two will appear only when I click on any of these other two, so you understand better, follow my code:

$(".membrosClick").click(function() {
  $(".listagemEsc").show();
});
$(".membrosFechar").click(function() {
  $(".listagemEsc").hide();
});
.membros {
  position: relative;
  width: 1120px
}
.membros li {
  float: left;
  cursor: pointer;
}
.membros li>div.subir>h2 {
  font-family: "bebasneue_regular";
  font-size: 67.99px;
  color: #ffffff;
  text-transform: uppercase;
  margin-top: 350px;
  margin-left: 65px;
  height: 59px;
  line-height: 59px;
}
.membros li>div.subir>h3 {
  font-family: "bebasneue_light";
  font-size: 67.99px;
  color: #ffffff;
  text-transform: uppercase;
  margin-left: 65px;
  height: 59px;
  line-height: 59px;
}
.membros li:hover .barraNone {
  display: block;
}
.membros li:hover .subir {
  margin-top: -10px;
}
<li class="editable membrosClick" name="Listagem de Membros" style="background-image: url('./imagens/membro1.jpg'); width:383px; height:849px">
  <div class="subir">
    <h2>Antônio</h2>
    <h3>Guerra</h3>	
  </div>
  <div class="bandaBarra bandaBarraBranca margin-left-65 margin-top-10 barraNone"></div>
</li>
<li class="listagemEsc p-relative">
  <div class="membrosFechar"></div>
  <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo.</span>
</li>
<li class="editable membrosClick" name="Listagem de Membros" style="background-image: url('./imagens/membro2.jpg'); width:383px; height:849px">
  <div class="subir">
    <h2>Antônio</h2>
    <h3>Guerra</h3>	
  </div>
  <div class="bandaBarra bandaBarraBranca margin-left-65 margin-top-10 barraNone"></div>
</li>

What is to happen: When I click on li members to li next door listing should appear. Okay, this is happening, only appear all listing of the website. I should use parent, closest? in Jquery?

  • I think you can use .next()... $(".membrosClick").click(function () {&#xA; $(this).next().toggle();&#xA;});

  • @Sergio was just what I needed, grade 10!

1 answer

3


If the li are followed (siblings/siblings) can use the .next() that selects the next sibling of that element. Example:

$(".membrosClick").click(function () {
    $(this).next().toggle();
});

jsFiddle: http://jsfiddle.net/53zgvwfj/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.