我有这个代码是完全工作的。当我单击单选按钮时,它会将用户重定向到网页的下一部分(即: div id="profiel")
<script>
$("input[name='gender']").change(function(){
window.location = "#profiel";
});
</script>单选按钮:
<input type="radio" id="female" name="gender">
<input type="radio" id="male" name="gender">我希望到锚标签的转换要慢一些。这样页面就会慢慢向下滚动。现在它立即进入#profiel部分。我以前见过这个,只是我自己不知道该怎么做。
发布于 2018-04-26 13:54:35
试试这个:
<script>
$("input[name='gender']").change(function(){
$('html, body').animate({
scrollTop: $("#profiel").offset().top
}, 2000);
});
</script>发布于 2018-04-26 13:59:17
有一个jquery插件名Nicescroll,您可以使用它的代码是
$("input[name=gender]").change(function(){
$('html').nicescroll()
window.location = "#profiel";});
或者,如果您想要添加转换:1在您的css主体或html样式中都很容易进入,但我不确定这一点,但nicescroll插件肯定会起作用。
https://stackoverflow.com/questions/50044713
复制相似问题