I need to get the height of three divs, add them together and see if the scroll position is great than that number. Right now I am able to get the height of one element, but how could I add others in?
Basically, I want to write "if scroll_top is greater than the height of div 1 + div 2 + 3"
var scroll_top = $(window).scrollTop();
if ((scroll_top > $('.nav-bar-fixed').height()) {
alert('sometext');
}
Why not simply this ?
Try this:
Here is a fixed nav sample and source.
This should do the trick.
Working example on JS Bin.
HTML:
CSS:
JavaScript:
You could implement this JQuery based function:
And then call it like this: