我希望 Jquery 将一个类添加.pointer
到.staff-container
if<a href="">
存在于.staff-picture
.
我的jQuery:
if($('.staff-container').find('.staff-picture').closest('a').length) {
$(this).addClass('pointer');
}
上面的 jquery 没有添加任何类,我做错了什么?
我的CSS:
.pointer {
cursor:pointer !important;
}
我的 HTML:
<div class="teachers">
<div class="span12">
<div class="scroll transparent">
<div class="staff-outer-container">
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<a href="http://ahmedmathematics.weebly.com/index.html" target="_blank"><img src="img/people/teachers/ahmed.png" /></a>
</div>
<p><span class="bold">Mr. Ahmed</span><br />
Ext. 13417<br />
Room 417/323<br />
<a href="mailto:Ahmed@wcskids.net">Ahmed@wcskids.net</a></p>
</div>
</div>
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<img src="img/people/teachers/aiello.png" />
</div>
<p><span class="bold">Mr. Aiello</span><br />
Ext. 13328<br />
Room 328/323<br />
<a href="mailto:ASusan@wcskids.net">ASusan@wcskids.net</a></p>
</div>
</div>
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<a href="http://www.mraiosa.com/class/Home.html" target="_blank"><img src="img/people/teachers/aiosa.png" /></a>
</div>
<p><span class="bold">Mr. Aiosa</span><br />
Ext. 13419<br />
Room 419/323<br />
<a href="mailto:BAiosa@wcskids.net">BAiosa@wcskids.net</a></p>
</div>
</div>
</div>
</div>
</div>
</div>