<div id="media">
<div id="table-pane">
<img src="..." class="img-thumbnail">
<img src="..." class="img-thumbnail selected">
<img src="..." class="img-thumbnail">
</div>
</div>
我想如果在子元素中选择了类返回true。我的代码
$("#media").hasClass('.selected');
总是返回false ???
答案 0 :(得分:0)
$(function(){
if($('#media').children().children().hasClass('selected')){
alert('class was found');
}else{
alert('class was not found');
}
})