There is a list of ul li

 <ul class="donate_ul"> <li>текст <p>текст</p> </li> <li>текст</li> <li>текст</li> <li>текст</li> </ul> <script> $(function(){ $('.donate_ul li').click(function(){ $('.donate_ul p').toggle(this); }) }) </script> 

How to make it appear when clicking on li

    1 answer 1

    You need to change the context, where to look for p . This is done like this: $('p', this).toggle(); where p is an element, this is the current li on which the click was made.

     $(function(){ $('.donate_ul li').click(function(){ $('p', this).toggle(); }) }) 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="donate_ul"> <li>текст <p>текст1</p> </li> <li>текст </li> <li>текст <p>текст3</p> </li> <li>текст</li> </ul>