我正在尝试使用 mouseenter 显示一个类,如下所示:
$(".stcommenttext").live({
mouseenter:
function() {
$(this).attr('class');
},
mouseleave:
function() {
}
}
);
我的 HTML 和 CSS 如下所示:
<div class="stcommentbody" id='stcommentbody19'>
<div class="stcommentimg">
<a href="/view_profile.php?id=5" style="border:0;"><img src="/photos/files/5/main/small_thumb.jpg?v=1348065832" class='small_face'/></a>
</div>
<div class="stcommenttext">
<input type="hidden" id="home19" value="1" />
<a class="stcommentdelete" href="#" id="cmt_19" rel="tooltip" title="Delete Comment"></a>
<a href="/view_profile.php?id=5" style="border:0;"><b>psmith</b></a> hello <div class="stcommenttime">8 minutes ago <span style="float:right;"><img id="delcmticon_69" class="saving" src="/images/busy.gif" /></span></div>
</div>
</div>
<div class="stcommentbody" id='stcommentbody20'>
<div class="stcommentimg">
<a href="/view_profile.php?id=5" style="border:0;"><img src="/photos/files/5/main/small_thumb.jpg?v=1348065832" class='small_face'/></a>
</div>
<div class="stcommenttext">
<input type="hidden" id="home20" value="1" />
<a class="stcommentdelete" href="#" id="cmt_20" rel="tooltip" title="Delete Comment"></a>
<a href="/view_profile.php?id=5" style="border:0;"><b>psmith</b></a> testing this <div class="stcommenttime">7 minutes ago <span style="float:right;"><img id="delcmticon_69" class="saving" src="/images/busy.gif" /></span></div>
</div>
</div>
</div>
CSS:
.stcommentdelete {
float:right;
cursor:pointer;
background:url(/wall/icons/trashdull.png);
display: none;
height:20px;
width:20px;
}
.stbody:hover .stcommentdelete {
display: block;
}
.stcommentdelete:hover {
background:url(/wall/icons/trash.png);
}
我希望它会在鼠标输入时为单个 div 显示我的删除图标,但它会显示所有 div 的图标。知道我错过了什么吗?