I want to make the script load into the div only when user reaches it. I am trying to accomplish this using jQuery, but no success. Maybe you can help. Here is the code:
var scrollFromTop = $("#float_div_id").offset().top;
$(document).scroll(function () {
if ($(this).scrollTop() > scrollFromTop) {
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.src = 'javascript code src which i want to append on scroll';
document.getElementById('float_div_id').appendChild(s);
}
});
console.logto check if ever thescrollTop()value goes beyond the offset.