循环遍历某些元素,实现点击选中的样式 li,
$(document).on('click',"#id",function(){
if(!$(this).hasClass(".select")){
$(this).sublings(".select").removeClass(".select");
$(this).addClass(".select");
}
})
点击div之外实现隐藏 当前div 的子集 效果(js)
<div class="filterBox">
<div class="filter">
<span>
<span>1栋</span>
<i class="aidicon aidicon-arrow-down-drop"></i>
</span>
<span>
<span>1栋</span>
<i class="aidicon aidicon-arrow-down-drop"></i>
</span>
<span>
<span>1栋</span>
<i class="aidicon aidicon-arrow-down-drop"></i>
</span>
<span>
<span>1栋</span>
<i class="aidicon aidicon-arrow-down-drop"></i>
</span>
</div>
<div class="filterList"></div>
</div>
<div class="listBox"></div>
<script>
$(document).on('click',function(e){
var length = $(e.target).parents('.filterBox').length;
console.log(length);
if(length == 1){
}else {
$filterList.empty();
}
})
</script>