【发布时间】:2014-04-03 02:33:20
【问题描述】:
当我将其悬停时,我正在尝试将类 .hover 添加/删除到链接<a href="#" id="permalink"></a>。但它不工作!看看吧:
CSS
#content-r #right #post-outer {
width: 264px;
height: 264px;
background: #1f1f1f;
-webkit-column-break-inside: avoid;
-moz-column-break-inside: avoid;
column-break-inside: avoid;
display: inline-block;
overflow: hidden;
color: white;
margin-top: 11px;
position: relative;
margin-bottom: -5px;
margin-right: 7px;
}
#content-r #right #post-outer a {
padding: 0px 0px 245px 260px;
position: relative;
z-index: 997;
color: white;
margin-left: 4px;
}
#content-r #right #post-outer .body {
position: absolute;
padding: 0px 19px 0px 19px;
bottom: 0;
width: 226px;
z-index: 997;
}
#content-r #right #post-outer .body .track{
font-size: 20px;
margin-bottom: -20px;
position: relative;
}
#content-r #right #post-outer .body .artist{
font-size: 20px;
margin-bottom: -20px;
position: relative;
}
#content-r #right #post-outer .body .feat{
font-size: 15px;
line-height: 18px;
margin-top: 3px;
position: relative;
}
.hover{
width: 263px;
height: 263px;
background: url('https://dl.dropboxusercontent.com/u/274369538/images/body-hover.png') -1px 0px;
position: absolute;
}
HTML
<div id="post-outer">
<a href="#" id="permalink"></a>
<div class="body">
<div class="track">Track here</div>
<div class="artist">Artist here</div>
<div class="feat">Featuring here</div>
</div>
<div class="image">
<img src="MY-IMAGE-HERE" width="264" height="264">
</div>
我尝试使用这个 jQuery,但没有成功:
$('#permalink').mouseenter(function() {
$('#post-outer').find('a').addClass('hover');
});
谢谢!
(这是我使用这些代码的链接:http://www.comocanta.com.br/)
【问题讨论】:
-
似乎工作正常here?
-
你是否包含了 jQuery,使用 document.ready 等
标签: jquery hover addclass removeclass