我試圖使用顯示像mousenter這樣一類:的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的圖標。任何想法我失蹤?
你正在使用哪個版本的jquery。如果1.7+你應該使用'on'來代替'live'。這是實際的代碼?因爲'$(this).attr('class');'什麼都不做。 –
我正在使用1.7 + – Paul
你說你想「顯示課程」。顯示一個類在哪裏?這行代碼'$(this).attr('class');'不會做任何事情...... – devnull69