我有以下代码,当您单击 a.discover 时会为元素设置动画:
$(document).on('click', 'a.discover', function(e){
e.preventDefault();
if(toggleState) {
$(this).addClass('open');
$(this).parent().find('p.subtitle').stop(true,true).animate({'marginTop': -471}, 1200, "easeOutQuart" );
} else {
$(this).parent().find('p.subtitle').stop(true,true).animate({'marginTop': 21}, 1200, "easeOutQuart" );
$(this).removeClass('open');
}
toggleState = !toggleState;
});
HTML
<div class="container">
<p class="subtitle">Released on July 2013</p>
<a href="" class="discover">Discover Now</a>
<p class="subtitle">Released on July 2013</p>
<a href="" class="discover">Discover Now</a>
<p class="subtitle">Released on July 2013</p>
<a href="" class="discover">Discover Now</a>
</div>
CSS
.container a.discover{
z-index: 100;
display:block;
position:absolute;
width:100%;
color:#fff;
text-decoration:none;
text-transform:uppercase;
bottom:0px;
text-align:center;
font-size:11px;
font-family: 'univers_55regular', arial,helvetica,clean,sans-serif;
padding-top:6px;
padding-bottom:6px;
background: url("../img/cross.png") no-repeat scroll 73px 7px #000;
}
.container p.subtitle{
font-family: 'univers_45_lightregular', arial,helvetica,clean,sans-serif;
font-size:12px;
color:#000;
margin-top:21px;
}
.container{
width:930px;
margin-left:35px;
}
我有 3 个这样的按钮,所以当您单击一个以对其进行动画处理时,您需要单击另一个按钮两次才能工作。一个想法可能出了什么问题?谢谢!