Check if the jQuery object contains any element before you try to get its offset:
var nav = $('.content-nav');
if (nav.length) {
var contentNav = nav.offset().top;
...continue to set up the menu
}
More Related Contents:
- How to get on-screen visible element objects in jQuery? [duplicate]
- JS hide function error
- Get the longest text in HTML document using Jquery or javascript
- Javascript counting all the characters from a HTML document
- Check if an element contains a class in JavaScript?
- JSFiddle code not working in my own page
- How to disable scroll without hiding it?
- Is there a DOM event that fires when an HTML select element is closed?
- jQuery: Get selected element tag name
- How to dynamically create ‘@-Keyframe’ CSS animations?
- Infinity Loop Slider Concepts
- Text blinking jQuery
- jQuery jump or scroll to certain position, div or target on the page from button onclick [duplicate]
- jQuery vs document.querySelectorAll
- How to ONLY trigger parent click event when a child is clicked
- How can I detect when a new element has been added to the document in jquery?
- JavaScript Loading Screen while page loads
- Change text color based on brightness of the covered background area?
- jQuery – Sticky header that shrinks when scrolling down
- Show text letter by letter
- collapse and expand tabs jquery / simple accordion
- How can I get access to a Highcharts chart through a DOM-Container?
- Remove scrollbar but not scrolling functionality [duplicate]
- How can I remove wrapper (parent element) without removing the child?
- Gaussian Blur onHover Using jQuery
- Pausing CSS animation with javascript and also jumping to a specific place in the animation
- fade effect using javascript no jquery?
- Detect if dropdown navigation would go off screen and reposition it
- Iframe inherit from parent
- Bootstrap Dropdown menu is not working