我試圖在頁面加載後立即在標題上創建一個過渡效果(從底部到頂部),但我無法弄清楚爲什麼它不工作。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 /)直接。 –