html - jquery closest anchor in view port -


I am developing a one page website where I have two images on the "joystick" mouseover Down Navigation, I can easily manage it with jquery .scroll () method and jquery

on that page, I have many anchors I have another behavior Want - When a user clicks on the up or down arrow, I want to scroll the page to the nearest anchor on the page. - When the user clicks " above ", the last anchor button and the closest " anchor " when the user clicks the down arrow

because My scroller has been stabilized, .closest () jquery method does not work. What is the way to find the nearest anchors in the viewport?

JS Fidel:

  http://jsfiddle.net/8vW6n/1/   

Any help would be greatly appreciated

You can try doing something like this:

  $ (". Joystick .down"). Click (function () {var anchors = $ ('. Page & gt; a'); var anchorpopss = []; Anchors.each (function (ind, anch) {anchorpositions.push (anch.getBoundingClientRect (). );}); Var i; for (i = 0; i  gt; break; console.log (anchors.eq (i)) ; //anchors.eq(i) is the nearest anchor}}   



Comments

Popular posts from this blog

c - Performance of System() -

python - how we can use ajax() in views.py in django? -

python - Sequence Pattern recognition with Pybrain -