Scroll bottom in click event

3

I need the page to go down to the footer when it is clicked on a input .

In fact when the user clicks on input and starts typing, the jQuery autocomplete is hidden by the cellphone keypad, so when clicked on input and the mobile keyboard appears the page should go down to the end , so the input is more visible and you can see the autocomplete options.

I tried:

$("input").click(function(){
  $("html, body").animate(function(){
    scrollBottom: 1000
  }, 500)
});

but scrollBottom does not exist if I'm not mistaken ...

    
asked by anonymous 17.01.2017 / 14:12

1 answer

4

You can do it this way

$("input").click(function(){
    $("html, body").animate({ scrollTop: $(document).height() }, 500);
});

Source: stackoverflow in English

See:

$(function(){
    $("[data-toggle='bottom']").click(function(){
  	$("html, body").animate({ scrollTop: $(document).height() }, "slow");
    });
});
div{
  width:300px;
  height:1000px;
  background:#000;
}
<body>
  <button data-toggle="bottom">Descer</button>
  <div></div>
</body>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    
17.01.2017 / 14:15