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 - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -