d-_-b d-_-b - 17 days ago 5
jQuery Question

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

In jquery, how can I reference the parent of

$(this)
element with a
class
of 'abc'?

Answer

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.

Comments