jQuery - using $(this)


/ Published in: jQuery
Save to your folder(s)

Show/hide an paragraph when you click on the h2, suppose you have:

<a href="#">Designer info</a>
<p>Lorem ipsum dolor sit amet.</p>

You can show/hide the paragraph with the code below.


Copy this code and paste it in your HTML
  1. $('h2').click(function()
  2. {
  3. $(this).next().toggle('slow');
  4. })

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.