我有以下HTML:
<div class="main_links cf" id="main_link">
<a class="est_btn" name="single_pane" id="single_pane">
<span>Single Pane</span>
</a>
<a class="est_btn" name="single_with_storm" id="single_with_storm">
<span>Single with storm</span>
</a>
<a class="est_btn" name="double_pane" id="double_pane">
<span>Double pane</span>
</a>
<a class="est_btn" name="high-efficiency-windows" id="high-efficiency-windows">
<span>High efficiency windows (Low-E)</span>
</a>
</div>
现在我想要所有这些的至少一个锚标签应该有一个活动的类。谁能告诉我如何在jQuery中完成它?
提前致谢。
答案 0 :(得分:2)
试试这个:
if($("#main_link a.active").length!=0){
//element with active class exist
}
答案 1 :(得分:0)
是的,有可能:
$('.main_links a').each(function(){
if($(this).hasClass('active'))
alert($(this).attr('id'));
});