Reputation: 3678
I have a simple html page with one text box. When it is clicked I want the page to scroll down. So I put an event listener on the text box and in it I use animate for the scrolling. But when I run this the scrolling is not happening...
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script >
$(document).ready(function() {
$("input").focus(function() {
$("html, body").animate(scrollTop: $(window).scrollTop() + 400);
})
});
</script>
</head>
<body>
<input type="text">
Upvotes: 0
Views: 61
Reputation: 24001
you forgot { }
$("html, body").animate({scrollTop: $(window).scrollTop() + 400} , 1000);
Upvotes: 3