jquery change input value when scroll to div -
edited:
Resolved
I change the value of the input Tried the mouse to scroll to that page.
HTML:
& lt; Div class = "pagenum" & gt; Page number: & lt; Input type = "text" id = "page name" & gt; / 3 & lt; / Div & gt; & Lt; Div class = "page-container" & gt; & Lt; Div class = "page" id = "page -1" data-page-no = "1" & gt; This is div # 1 & lt; / Div & gt; & Lt; Div class = "page" id = "page-2" data-page-no = "2" & gt; This div # 2 & lt; / Div & gt; & Lt; Div class = "page" id = "page -3" data-page -n = "3" & gt; This div # 3 is & lt; / Div & gt; & Lt; / Div & gt;
CSS:
.page-container {padding-top: 30px; Width: 300px; Height: 1500px; }. Page {height: 300px; Limit: 1px solid # 000; Margin: 5 px; }. Pagenum {background: #fff; Status: fixed; Limit: 1px solid # 000; Width: 300px; }
JS:
$ (window) .scroll (function) {var pagenum = $ ('. Page'). Attr (' Data-Page-No '); $ ("#PageGename") .Well (Perjum);});
But it can not do as much as I want.
Can anyone help me?
More: When filling a number in the input box, I
Want to live
JQuery code that I use:
var disable_scroll = false; $ (Window) .scroll (function) {if (disable_scroll == false) {if ($ (window) .scrollTop () & gt; = $ ("# page-1"). Offset () top. {Var pagenum = $ ("# page-1"). Attr ('data-page-no');} ($ (window) .scrollTop ()> = $ ("# page-2") Offset () .top) {var pagenum = $ ("# page-2"). Attr ('data-page-no');} ($ (window) .scrollTop () & gt; = $ ("# page -3 etr ('Data Page-No');} $ ("#PageGename"). Val (Perjum);}}); $ ("$$"). ('Input', function () {$ ( ". Page"). Each (function () {if ($ (this) .attr ('data-page-no') = = $ ("#page_cache"). Val ()) {disable_scroll = true; var selected = $ (This); $ ('html, body'). Animate ({scrollTop: $ (this) .offset (). + 1}, function () {var pagenum = $ ( Yanti) .attr ('data-page-no'); $ ("# pagenum"). Val (pagenum); disable_scroll = false;}); return;}});});
Check it ...
Comments
Post a Comment