Jquery 如何在最近的DIV之前获取DIV

Jquery 如何在最近的DIV之前获取DIV,jquery,html,css,Jquery,Html,Css,当您将鼠标悬停在My文本上时,myicon.png会淡出,然后返回: <div class="mmItemStyleChild"> <img src="theImages/myicon.png" class="mIcon vertAlign mmm1" id="mMW1" /> <img src="theImages/emptyImg.png" class="mSpacerStyle" /><span id="mMW" class="vertAl

当您将鼠标悬停在
My
文本上时,
myicon.png
会淡出,然后返回:

<div class="mmItemStyleChild">
    <img src="theImages/myicon.png" class="mIcon vertAlign mmm1" id="mMW1" /> <img src="theImages/emptyImg.png" class="mSpacerStyle" /><span id="mMW" class="vertAlign mmm">My</span>
</div>

$('.mmm').hover(function () {
    $(this).closest('div').find('img').first().stop().animate({ 'opacity': .35 });
}, function () {
    $(this).closest('div').find('img').first().stop().animate({ 'opacity': 1 });
});

我的
$('.mmm').hover(函数(){
$(this).closest('div').find('img').first().stop().animate({'opacity':.35});
},函数(){
$(this).closest('div').find('img').first().stop().animate({'opacity':1});
});
我试图对以下内容执行相同的操作,但不起作用:

<div class="mBtnMidS mBtnMidStyle">
    <div>
        <img id="mbS1" src="theImages/services_icon.png" class="mBtnIcon" />
    </div>
    <div>
        <span id="mbS" class="mbBtnText">Services</span>
    </div>
</div>

$('.mbBtnText').hover(function () {
    $(this).closest('div').find('img').first().stop().animate({ 'opacity': .55 });
}, function () {
    $(this).closest('div').find('img').first().stop().animate({ 'opacity': 1 });
});

服务
$('.mbBtnText')。悬停(函数(){
$(this).closest('div').find('img').first().stop().animate({'opacity':.55});
},函数(){
$(this).closest('div').find('img').first().stop().animate({'opacity':1});
});

如何修改上述代码,使其从父DIV(使用类'mBtnMidS'或'mBtnMidStyle')查看,并获取图像,并执行与第二个代码块更改中的第一个脚本相同的淡入淡出动画:

$(this).closest('div')
致:

按照您的方式,最近的div是span的父div,但您需要该div的父div(span的祖父母div)

$(this).closest('div.mBtnMidS.mBtnMidStyle')