Trying to adjust the page to offset a fixed header.
Works outside of xF. In xF, if I use <script> I get an error ($ undefined), and if I put it in <xf:js> nothing happens. What am I doing wrong?
JavaScript:
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 40);
}
}
$(document).on('click', 'a[href^="#"]', function(event) {
window.setTimeout(function() {
offsetAnchor();
}, 0);
});
window.setTimeout(offsetAnchor, 0);
Works outside of xF. In xF, if I use <script> I get an error ($ undefined), and if I put it in <xf:js> nothing happens. What am I doing wrong?