我是Jquery的业余爱好者,但我非常接近获取我所需要的东西。我试图让一个包含div的元素在点击对象时具有更大的高度。我使用下面的代码:使用JQuery来动画Div的大小
<div id="sliderone">
<div id="nav">
<div id="navone" style="text-align: center;">This is a clickable title</div>
</div>
<div id="ourteam">
<div id="title"></div>
</div>
</div>
<script type="text/javascript">
$('#navone').click(function(){
$('#title').html("<img src='http://placehold.it/350x550' alt='' />");
$('.post-8 .content-container').animate({height: '950'});
});
</script>
#navone {
padding:20px 20px;
cursor:pointer;
}
#title {
width:350px;
margin:0 auto;
}
#sliderone {
height:50px;
background-color:#777777;
position: absolute;
margin-top: -500px;
left: 50%;
margin-left: -175px;
}
#sliderone
必须绝对定位,所以当我尝试动画.post-8 .content-container
它使上边长的比较,而不是使底边长为包含新的内容。我可以动画缩小负边距还是动画底部的.post-8 .content-container
?
谢谢你的帮助。我在这方面努力工作,只是无法弄清楚最后一个问题。
下面是实际看到的页面。
http://s416809079.onlinehome.us/wp-login 登录:计算器 密码:计算器
这里看看http://www.w3schools.com/jquery/jquery_animate.asp – user2167382
什么关于使用jQuery库中的'slideDown'? –
您正在使用jQuery的类选择器,但这些类不存在于html中。你的选择器不会选择任何东西,因此不会动画。 – Bic