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

66,208

Solution 1

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.

Solution 2

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

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

Share:
66,208

Related videos on Youtube

d-_-b
Author by

d-_-b

(your about me is currently blank)

Updated on July 15, 2022

Comments

  • d-_-b
    d-_-b almost 2 years

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

  • d-_-b
    d-_-b over 11 years
    Thank you. I knew it was something simple I was overlooking