jQuery 获取相同 class元素的最后一个元素或id
jQuery 获取相同 class元素的最后一个元素或id
jQuery 获取一组相同 class 的元素中的最后一个元素,可以使用last()
或者 :last
。
如下:获取第三个j-bankAreaIdPath对应的id值。
<p id="bankAreaIdPath_0" class="j-bankAreaIdPath" name="bankAreaIdPath" data-name="bankAreaIdPath" level="0"></p> <p id="bankAreaIdPath_0_26" level="1" class="j-bankAreaIdPath" aria-required="true"></p> <p id="bankAreaIdPath_0_26_336" level="2" class="j-bankAreaIdPath" lastarea="1" aria-required="true"></p> <script> $(document).ready(function(){ var idpath = $(".j-bankAreaIdPath").last().attr("id"); alert(idpath); }); </script>
本文属原创,转载请注明原文:https://www.zhimatong.com/jiaocheng/948.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
内容有用
热门主题
相关阅读
- 苹果手机iOS设备,浏览器在 textarea 或 input 中输入文字时页面放大的解决办法
- select选择后直接跳转到其他网站的三种方式
- 详解CSS居中对齐的3种方式15个样例
- Echarts图表基本参数设置说明
- jQuery报错$(this).attr(‘checked‘)undefined/checkbox无法改变其状态的解决方法
- jq .html() 特效无效的解决办法
- 如何将iconfont中的字体图标全部展示在页面中
- HTML特殊字符符号大全
- jQuery清空input的值,清除标签内容的方法
- jQuery 获取相同 class元素的最后一个元素或id
- ajax传递data的三种传递方式
- jQuery跳转页面的3种代码示例