gpt4 book ai didi

jquery - 类名为 'x' 的引用 $(this).parent

转载 作者:行者123 更新时间:2023-12-03 21:45:31 24 4
gpt4 key购买 nike

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

最佳答案

像这样:

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

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

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

.parent().parents()类似,只是 .parent() 仅在 DOM 树中向上移动一级。

关于jquery - 类名为 'x' 的引用 $(this).parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11927854/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com