【发布时间】:2011-01-23 02:49:24
【问题描述】:
有没有更好的方法在 jQuery 中选择祖父元素以避免这种情况?
$(this).parent().parent().parent().parent().parent().children(".title, .meta").fadeIn("fast");
谢谢。
【问题讨论】:
-
那么 children().children().children().children(".title") 呢?
-
无法抗拒,您可以将 $(this).gparent(2) 与我投反对票的答案中提供的代码一起使用。不知道为什么它被否决,因为它是回答你问题的解决方案......