I have a button back-to-top
that is affixed to the left side of the screen - it uses scrollTop
to slide-scroll to the top of the page when it's clicked. When the page the loads, the button is visible and does not cover anything that is readable etc.
When a user scrolls down the page, the button goes over certain DIVs that have text content. When the button goes into such a DIV I want it to hide using .hide()
. Can't get it to work, here's what I have:
var p = $('a.back-to-top');
var position = p.position();
if(position == $('#about-me')){
$('a.back-to-top').hide();
}
Is if(position == $('#about-me'))
the correct way to check if the button's position is in the #about-me
DIV? Or, should I create a variable similar to position
for the DIV?
EDIT: A messy but simple fiddle