Example
by Udhay
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<p>Try the scrollbar in the div</p>
<div style="border:1px solid black;width:200px;height:100px;overflow:scroll;">In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
<br><br>
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
</div>
<p>Scrolled <span>0</span> times.</p>
<button>Trigger scroll event for the window</button>
CSS
textarea {
width: 4rem;
height: 8rem;
font-size: 3rem;
}
JavaScript
var x = 0;
$(document).ready(function(){
$("div").scroll(function(){
$("span").text( x+= 1);
});
$("button").click(function(){
$("div").scroll();
});
});