我想在页面加载时添加一些动画。我尝试了几次但没有成功。你能帮我解决一个jquery hack吗?
HTML& Jquery 部分:
<div class="MainPozEstate"><a href=""><img src="assets/img/mrk-sng.png" alt="Acarkent Markavilla"/></a></div>
<script type="text/javascript">
jQuery( document ).ready( function($) {
$( ".MainPozEstate a" ).mouseover( function() {
$( this ).children( "img" ).stop( true, true ).animate({
opacity: 0.6
}, 200, "swing", function() {
$( this ).animate({
opacity: 1
}, 400 );
});
});
});
</script>
CSS 行:
.MainPozEstate {float:left;width:980px;margin:0px auto;padding-top:30px;text-align:center;}
.MainPozEstate img {border:none;margin:0px auto;}
感谢。
答案 0 :(得分:1)
如果你想添加另一个效果,那么可以再做另一个电话。 http://jsfiddle.net/fedmich/w8HzE/2/
jQuery( document ).ready( function($) {
$( ".MainPozEstate a" ).mouseover( function() {
$( this ).children( "img" ).stop( true, true ).animate({
opacity: 0.6
}, 200, "swing", function() {
$( this ).animate({
opacity: 1
}, 400 );
});
});
//
});
jQuery( document ).ready( function($) {
//do your other effects here or just trigger/call mouseover if you want.
$( ".MainPozEstate a" ).mouseover();
});
我认为您的代码正常运行,http://jsfiddle.net/fedmich/w8HzE/