jquery - Load javascript into div when user scroll position reaches it -


i want make script load div when user reaches it. trying accomplish using jquery, no success. maybe can help. here 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 want append on scroll';         document.getelementbyid('float_div_id').appendchild(s);     } }); 

in case, $(this).scrolltop() coming out lesser scrollfromtop.

change if condition , try again :

if ($(this).scrolltop() + $(window).height()  > scrollfromtop) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -