Click on Jquery does not work

Asked

Viewed 363 times

0

According to this question I asked earlier and was resolved I have another question that happens after that.

$(".membrosClick").click(function() {
  var el = $(this);
  el.css("width", "766px");
  el.children().show();
});

$(".membrosFechar").click(function() {
  $(".listagemEsc").hide();
});
<li class="membrosClick">
  <div name="Listagem de Membros" style="background-image: url('./imagens/EDGAR-GUERRA.png'); width:383px; height:849px">
    <div class="editable subir">
      <h2>Edgar</h2>
      <h3>Guerra</h3>	
      <div class="bandaBarra bandaBarraBranca margin-left-65 margin-top-10 barraNone"></div>
    </div>

  </div>
  <div 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>
  </div>
</li>
<li class="membrosClick">
  <div name="Listagem de Membros" style="background-image: url('./imagens/ANTONIO-GUERRA.png'); width:383px; height:849px">
    <div class="editable subir">
      <h2>Antônio</h2>
      <h3>Guerra</h3>	
      <div class="bandaBarra bandaBarraBranca margin-left-65 margin-top-10 barraNone"></div>
    </div>

  </div>
  <div 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>
  </div>
</li>

When I click on membrosClick he leaves the div with 766px. With that the div listagemDesc appears. This is working perfectly. However, there is a div inside called membrosFechar, which is an X I made for when the user click, the div listagemDesc keep display:hide and I think the ideal is also the div membrosClick get 383px, which is its original size before the click. I’m not getting it done.


UPDATE

I figured it out, just include the event.stopPropagation(); as answered in Soen.

  • Dude, always look at the browser error console, it at all times will show you where the error is happening.

  • Dude, create the answer to your problem and mark it as right, so it makes it easier when, in the future, someone has the same problem.

1 answer

1

$('.listagemEsc').click(function(){
    $(this).parent('.membrosClick').width(383);
});

Updated:

$('.membrosFechar').click(function(){
    $(this).parent().parent('.membrosClick').width(383);
});

Updated:

$('.membrosFechar').on('click', function(){
    $(this).parent().parent().css('width', '383px');
});

If it doesn’t work I give up rsrs

$('.membrosFechar').on('click', function(){
    $(this).parent().parent().css('width', '383px');
    $(this).parent().hide();
});
  • It didn’t work, I had tried it before, look here http://www.musicalabertura.com.br/site/ in MEMBERS, when you click on a it opens a description on the side with the option to close, that’s what I wanted.

  • hasn’t worked yet, buddy.

  • 1

    I saw that when you click to open the box with the text works, but after a few seconds your console gets full of notifications with errors, maybe these errors may be bothering you.

  • in fact those errors are related to a plugin for Youtube, which in principle does not interfere with it, otherwise it would already give error before opening the description

  • Your syntax seems to be perfectly correct, but it has no effect on the site.

  • thanks for the effort friend. I thought the (document).ready it was closing before, but it doesn’t look like it didn’t, unfortunately it didn’t work =/

  • I was analyzing, in the last two updates you made, you reported the width, but did not report that it was the membrosClick

  • I managed to solve, updated my question! D

Show 3 more comments

Browser other questions tagged

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