Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set margin top for a DIV using JQuery

Tags:

Here is the situation, i have a fixed header with 120px height, and i forced the page to jump to #testdiv when the query string is #testdiv.

But the issue is when page jumps to beginning of the above DIV, part of the content will be lost,because it's behind the fixed header, is there any jquery to force page to jump to the #testdiv with not actual margin?

I tried the below code but it makes actual margin

if (url.indexOf('#testdiv') >= 0) { $('#testdiv').css('margin-top',120); };