div中具有类名称的最后一个元素 [英] last element with a class name in a div

查看:77
本文介绍了div中具有类名称的最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在id = test的div中获得类a的最后一个div? 在这种情况下,我必须获取content = 1000的div

how can i get the last div with class a in a div the id = test ? in this case i have to get the div with content = 1000

<div id="test">
<div class="a">1</div>
..
..
<div class="a>1000</div>
</div>

推荐答案

您可以使用 :last伪选择器:

You can use the :last pseudo-selector:

$('#test div.a:last')

这篇关于div中具有类名称的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆