根据其类名查找div id [英] Finding div id on the basis of its class name
本文介绍了根据其类名查找div id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须根据其类查找div ID,如果div具有名为searchItemSelected的类,那么如何获取其div ID.
I have to find div id on the basis of its class, if the div have class named searchItemSelected, then how to get its div id.
<div id="CheckinWithUser_4" class="CheckinWithUserRow1 searchItemSelected" onclick="" style="overflow: visible; height: 40px;">
推荐答案
可以通过.attr()方法访问元素的所有属性:
All attributes of an element can be accessed through the .attr() method:
var id = $('.searchItemSelect').attr('id');
这篇关于根据其类名查找div id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文