On the page this construction is repeated:

<div class="blok"> <p>Большая статья</p> <a href="#" class="link">раскрыть</a> </div> 

The task is this: when you click on a link, you need to open exactly the block that I open and not all with the blok class.

  • you need to open up the father element. Is there such a function in jQuery? - June

2 answers 2

 $(document).ready(function() { $('.blok a').click(function(e){ e.preventDefault(); $(this).prev('p').show(); // как вариант $(this).closest('.blok').find('p:first').show(); }); }); 
  • Respect answered, sorry for bonal questions. Newbie - June
  • $ (this) .closest ('. blok'). find ('p: first'). show (); a lot of magic where it is not needed =) - Zowie
  • I wrote "as an option" - aachurin
 $(document).ready(function() { $('.blok a').click(function() { $(this).parent().find('p').show(); return false; }); }); 
  • mine something is not right - aachurin
  • Corrected. It's time to sleep) - Sh4dow
  • Yeah, just still preventDefault on the link call, otherwise the anchor will go - aachurin
  • return false already cancels the default action. - LeD4eG