간단한 문제가 있습니다. 나의 아침 차는 충분히 강하지 않다.jQuery div에 앵커 하위가있는 경우
IF div에는 앵커 인 아동이 있습니다.
(대부분의 jQuery 방법 같은)children
방법이를 반환
$('.box').click(function(){
if ($(this).children('a').length) {
//some thing
} else {
//some thing else
}
});
이후 :
$('.box').click(function(){
if ($(this).children('a')) {
//some thing
} else {
//some thing else
}
});
<div class="box"><a href="#"><img src="#" /></a></div>
<div class="box"><img src="#" /></div>
<div class="box"><img src="#" /></div>
당신이'그가 앵커에 추가 CSS 할 몇 가지 thing', 그것은 연기하는거야의 자식 때 야유를 식별하는 CSS 하위 선택 "연기하는거야> 야유"를 사용하는 것을 고려하십시오