Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Javascript function to check if an element and/or its parents position is set to fixed
isPositionFixed = function (selector, traverseAncestors) {
var el = $(selector);
if (el.length) {
if (!traverseAncestors) {
return 'fixed' === el.css('position') ? true : false ;
var isFixed = false;
var els = el.add(el.parents());
els.each(function() {
if ('fixed' === $(this).css('position')) {
isFixed = true;
return false;
return isFixed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment