jQuery parent selector methods

Over the past couple of weeks I’ve stumbled over the same issue with jQuery a number of times. When you’re in an each loop within jQuery or some other reason when you’re using $(this), I continually have problems with finding and selecting a parent of $(this)

After a bit of searching, I’ve come across a lifesaver function built into jQuery. Closest()!

Quite simply…

$(this).closest('.class-name')

Seems to be working pretty good so far! :)

 

2 comments about jQuery parent selector methods

  1. Michele says:

    tnx from a newbie :D

  2. This function is working great with this j query development. I have been implemented this stuff in my project and it is beneficial for me. so thanks for this update.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>