Compare the page scroll position to your element top position, than call your function.
jQuery
$(document).on('scroll', function() {
if ($(this).scrollTop() >= $('#theTarget').position().top) {
console.log('I have been reached');
}
})
I have been reached
ES6 (Pure JS, no jQuery)
var target = document.querySelector('#theTarget');
document.addEventListener('scroll', () => {
if (window.scrollY >= target.getBoundingClientRect().top) {
console.log('I have been reached');
}
})
I have been reached