Reference $(this).parent with class name of 'x'

In jquery, how can I refer to the parent of $(this) element with a class of 'abc'?

Answers


Like this:

$(this).parents('.abc');

or

$(this).parent('.abc');

or

$(this).closest('.abc');

.parent() and .parents() are similar except that .parent() only travels up one level in the DOM tree.


<script>$(this).parent(".abc")</script>

http://api.jquery.com/parent/


Need Your Help

Plugin Architecture in Web Apps (Examples or Code Snippets?)

design-patterns web-applications architecture frameworks

I am trying to learn to develop a web application (preferably NodeJS/MongoDB, although I used PHP and Python before) that is highly extensible and customizable via plugins to enable disabled

Cordova list all files from application directory (WWW)

html5 cordova cordova-plugins

I am using Cordova 4.2.0 with plugins File and media. I have some mp3 files in audio folder inside www directory. I am able to play files through media plugin using path cordova.file.applicationDir...