I have a div that is position: fixed. I am trying to scroll to an element inside that div.
$('.example').animate({
scrollTop: $(".npwfu-ex").offset().top
}, 750);
Sometimes it scrolls to the right position. Sometimes not. How can I fix this?
Here's the CSS for the div with class "example":
.example {
position: fixed;
overflow: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
use this code if it works for you
$(document).ready(function()
{
var objDiv = document.getElementById("you element id");
objDiv.scrollTop = objDiv.scrollHeight;
});
this code scroll down or scroll up to your div element
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.