Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Add units to offset

Tags:

jquery

offset

Small problem. I have a div id="comHere" somewhere in the middle of the design. And at the top of the design, I have an <a href="#comeHere">Click Here</a>.

Now, when I click on the href link, it scrolls to the div using this code

scrollTop: $($anchor.attr('href')).offset().top

My requirement is that, say the div is having a position offset of 600px from top, when I click on the link I want the scroll to happen to 600px+100px and not to 600px.

Is this possible using jQuery ?

Thanks, Dev

like image 221
Dev Avatar asked Jun 09 '12 15:06

Dev


1 Answers

scrollTop: $($anchor.attr('href')).offset().top - 100
like image 103
thecodeparadox Avatar answered Oct 21 '22 12:10

thecodeparadox