I think something closer would be like below, but I would need to know more details about why you need this code.
window.addEventListener('load', function () {
document.querySelector("#table").addEventListener('scroll', function() {
if (this.scrollTop + this.offsetHeight == this.scrollHeight) {
console.log('final')
}
});
})
Just a little fix: jQuery is Javascript, not a language. In the case, you are not "converting to javascript", but using pure Javascript without the library.
I've done a better example to check out:
window.addEventListener('load', function () {
document.querySelector("#table").addEventListener('scroll', function() {
if (Math.ceil(this.scrollTop) + this.offsetHeight == this.scrollHeight) {
console.log('final')
}
});
})
#table{
max-height: 150px;
background-color: #ddd;
overflow: auto;
}
<div id="table">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
</div>