我试图在页面加载后立即在标题上创建一个过渡效果(从底部到顶部),但我无法弄清楚为什么它不工作。jQuery触发器不工作
HTML:
<div class="portfolio-title-wrap animate">
<div class="portfolio-title">Rooftop Garden </div>
<div class="location">San Francisco, CA</div>
</div>
CSS:
.animate {
background-color: #c00;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
position: absolute;
top: 100%;
right: 0;
}
.animate.move {
top: 0%;
margin-top: -700px;
}
.portfolio-title {
color: #F8941F;
font-weight:bold;
}
的jQuery:
jQuery('.animate').trigger(
function() {
$(this).addClass("move");
});
演示:Fiddle
在您的小提琴中,从左侧的下拉列表中选择jQuery。而且,除了别的之外,你期望这个代码做什么,它没有做什么?顺便提一句,['trigger()'](http://api.jquery.com/trigger/)触发*事件*,你需要的是使用['addClass()'](http://api.jquery .com/animate /)直接。 –