[英]how to scroll a div to top with easing effect in jquery?
I want to show a scrolling effect with click event , so i have a page with two divs. 我想显示带有click event的滚动效果,所以我有一个包含两个div的页面。 One works at the page load and another div, I want to hide and when a button with sign up is clicked it should come up top with scroll effect and become visible with form.
一个工作于页面加载,另一个工作于div,我想隐藏,当单击带有注册的按钮时,它应位于顶部并具有滚动效果,并在表单中可见。
please help as i am newbie in jquery 请帮助,因为我是jquery的新手
Try this, it is the full script 试试这个,它是完整的脚本
<div style="height:300px;width:50px;border:1px solid #a0a0a0;background-color:#c0c0c0">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<button id="show">Show</button>
<button id="hide">Hide</button>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("div").slideUp();
});
$("#show").click(function(){
$("div").slideDown();
});
});
</script>
To verify you can take help of http://htmledit.squarefree.com/ 要进行验证,您可以寻求http://htmledit.squarefree.com/的帮助
Is this what you want? 这是你想要的吗? Check DEMO http://jsfiddle.net/yeyene/reWwx/303/
检查演示http://jsfiddle.net/yeyene/reWwx/303/
$(document).ready(function(){
$('#signUp').on('click',function(){
$('html, body').animate({
scrollTop: 0
}, 1000, function() {
$('#myForm').fadeIn(500);
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.