jQuery get the height from top
height, hyperlink, javascript, jquery
Solution
Use the offset()
$('.poplight').offset().top
If you need to scroll to that position:
$('html, body').animate({
scrollTop: $('.poplight').offset().top
}, 400);
If you need the distance from the top of the window to the current position based on scroll:
$(window).scrollTop()
Want to add that to the url:
$(".poplight").attr("href", "#" + $(window).scrollTop())
Problem
I need to get the height from top of the page to current scrollbar position and place it to my link: ``` <a class="poplight" rel="popup_name" href="#?w=here comes the value"></a> ``` How can I do this?