Some Va...">

Choosing the Next Brother $ (this) .parent ()

I have HTML that looks like this:

<div>
  <div class="value">
    <a href="#" class="clicker">Some Value</a>
  </div>
  <div class="heading">
    Some Name<img src="loading.gif" style="visibility:hidden">
  </div>
</div>

This can be repeated several times, depending on how many values ​​and headers you need to specify. Using jQuery, I connected a function that will be executed when a.clicker is clicked. As part of what happens, I would like to call show () on .heading img below. However, I just can't figure out how this should be chosen.

$('a.clicker').live("click", function() {

  // This next line, in my brain, works, but in reality it doesn't!
  $('.heading img', $(this).parent().parent()).show();

  // do some other AJAXy things
});

I noted a line that I think should do it, but it doesn't show img at all. I have been unsuccessfully looking at the documentation and stream for several hours.

Thanks for any help!

+3
source share
1 answer

. , .

$('a.clicker').live("click", function() {
    $(this).parent().parent().find('.heading img').show();
});

:

$('a.clicker').live("click", function() {
    $(this).parent().next('.heading img').show();
});
+12

Source: https://habr.com/ru/post/1722356/


All Articles