HTML:
7条回答 春和景丽 (楼主) 2021-01-14 10:00 You should use closest() which will traverse up the DOM until it finds the element you're after: $('a').closest('li'); If you were doing this the other way around (i.e. you had the li and wanted to find the a) you would use: $('li').find('a'); 0 讨论(0) 查看其它7个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
You should use closest() which will traverse up the DOM until it finds the element you're after:
$('a').closest('li');
If you were doing this the other way around (i.e. you had the li and wanted to find the a) you would use:
li
a
$('li').find('a');