Print result of .scrollTop in jQuery -
I am trying to show the value of the .scrollTop () function on the screen while scrolling up and down on the screen, but I can not get it to work. I'm clearly doing something stupid. Please let me know. :) Thanks. Here's a bella: OK, the solution was done to cache the window, and insert .ccrollTop () inside the curly braces. thanks for your cooperation. :) Solution: Hope this helps Here I got Scroll Postien and it has been added in the form of html in the id in which the ID is '#myDiv' working here For more details on scroll & lt; Body & gt; & Lt; Div id = "mydiv" & gt; & Lt; P & gt; ..... & lt; / P & gt; & Lt; / Div & gt; & Lt; Div id = "tall" & gt; & Lt; / Div & gt; & Lt; Script & gt; Var $ myVar = $ ('# myDiv'); Var $ myDist = $ window.scrollTop (); $ Window.on ('scroll', function () {$ myVar.text ($ myDist);}); & Lt; / Script & gt; & Lt; / Body & gt;
var $ window = $ (window); Var $ myVar = $ ('# myDiv'); Var $ myDist = 0; $ Window.on ('scroll', function () {$ myDist = $ window.scrollTop (); $ myVar.html ($ myDist);});
$ (Window) .scroll (function () {var scrps = $ (this) .scrollTop (); $ ('# myDiv') .html ('your scroll position is' + scrpos);});
Comments
Post a Comment