I have a DIV, with hidden overflow, the whole CSS block for that DIV looks like this:
.mainContainer .display_box .container .row .col_4 .dPost_box{
position:relative;
height:100%;
width: 100%;
overflow:hidden;
}
Then, I want to make the content of the DIV scroll every time I hover onto the element. However, it won't work. I have tried jQuery.scrollTop(), as well as updating regular scrollTop, it wouldn't work. I also tried using Smooth Scroll, and Autoscroll plugins but none of them would work either. My current Javascript looks like this:
function autoScroll(div){
setInterval(function() {
if (div.scrollTop() < div[0].scrollHeight - div.height()){
div.scrollTop(div.scrollTop() + 10);
}}, 1000);
}
$(document).on({mouseenter: function(){
autoScroll($(this));
}, mouseleave: function(){
}}, '.dPosts_post');
I've also tried:
function autoScroll(div){
setInterval(function() {
if (div.scrollTop() < div[0].scrollHeight - div.height()){
div.scrollTop[0] +=10;
}}, 1000);
}
But nothing would work.
Preferably, I want to make the autoScroll
function to work, but if there are any plugins that would work, I'd be more than happy to try them out.
Any thoughts would be appreciated. Thanks!