How can I modify the script below so that it doesn't throw an error when the ".fixit" element is not present in the DOM?
function fixedHeaders() {
var el = jQuery('.fixit'),
offset = el.offset(),
elHeight = el.height(),
scrollTop = jQuery(window).scrollTop()
if (((offset.top + 400) < scrollTop - el.height())) {
el.addClass('fixedElement');
}
if (scrollTop === 0) {
el.removeClass('fixedElement');
}
}
jQuery(function() {
jQuery(window)
.scroll(fixedHeaders)
.trigger("scroll");
});