22

在 jquery 中,如何使用 of 引用元素的父$(this)级?class'abc'

4

2 回答 2

43

像这样:

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

或者

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

或者

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

.parent().parents()相似,.parent()只是在 DOM 树中只向上移动一层。

于 2012-08-13T03:30:53.977 回答
1
<script>$(this).parent(".abc")</script>

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

于 2012-08-13T03:33:34.560 回答