Home > Cannot Read > Cannot Read Property 'top' Of Undefined Scroll

Cannot Read Property 'top' Of Undefined Scroll

Contents

Here's the code for both. $(document).ready(function () { var contentNav = $('.content-nav').offset().top; var stickyNav = function () { var scrollTop = $(window).scrollTop(); if (scrollTop > contentNav) { $('.content-nav').addClass('content-nav-sticky'); } else {; After some researching, I think the problem is that $('.content-nav').offset().top can't find the specified selector because it's on a different page. Why does low frequency RFID have a short read range? How can I declare independence from the United States and start my own micro nation? this contact form

You can see for yourself in this fiddle alert($('.content-nav').offset()); (you will see "undefined") To avoid crashing the whole code, you can have such code instead: var top = ($('.content-nav').offset() || { We recommend upgrading to the latest Safari, Google Chrome, or Firefox. Would that matter if it is a

or
? –Antonio Almeida Apr 8 '15 at 6:31 | show 2 more comments up vote 10 down vote Your document does not What is the temperature of the brakes after a typical landing? http://stackoverflow.com/questions/20175094/uncaught-typeerror-cannot-read-property-top-of-undefined

Cannot Read Property 'top' Of Undefined Scroll

Terms Privacy Security Status Help You can't perform that action at this time. smartscroll owner d4nyll commented Jun 15, 2015 @maoosi That's a very good point I didn't consider. The corresponding line of code in the source is 180: if (this.refs.menu && this.refs.focused && this.state.isOpen && !this.hasScrolledToOption) { let focusedOptionNode = ReactDOM.findDOMNode(this.refs.focused); let menuNode = ReactDOM.findDOMNode(this.refs.menu); menuNode.scrollTop = focusedOptionNode.offsetTop; this.hasScrolledToOption

Is adding the ‘tbl’ prefix to table names really a problem? In fact, no other jQuery code below that second line works at all unless they are placed above it. I just started my first real job, and have been asked to organize the office party. Uncaught Typeerror Cannot Read Property Top Of Undefined Wordpress How to reset the WiFi configuration in Raspbian What was Stan Lee's character reading on the bus in Doctor Strange The OK or FAIL column The cost of switching to electric

IB-VT commented May 13, 2015 Hi Daniel, thanks for the fast reply, the site is online at: www.ib-barwich.de/test I tried to figure out if there is any interacting with other scripts Uncaught Typeerror Cannot Read Property 'top' Of Undefined Bootstrap Reload to refresh your session. You signed out in another tab or window. http://stackoverflow.com/questions/26899844/offset-javascript-scroll-cannot-read-property-top-of-undefined-error Right now, the structure needs to be:

Where the section needs to be direct children of the container.

Personal Open source Business Explore Sign up Sign in Pricing Blog Support Search GitHub This repository Watch 1,864 Star 32,192 Fork 5,579 atom/atom Code Issues 1,755 Pull requests 100 Projects Uncaught Typeerror: Cannot Read Property 'scrolltop' Of Undefined JuanCrg90 changed the title from Problems using the component in Meteor 1.2 to Uncaught TypeError: Cannot read property 'offsetTop' of null Apr 29, 2016 hedaro commented May 25, 2016 I debugged smartscroll owner d4nyll commented May 13, 2015 Thanks for letting me know, do you think it'd be possible for you to host your site somewhere so I can directly debug from How to jump around the piano?

Uncaught Typeerror Cannot Read Property 'top' Of Undefined Bootstrap

however just wondering... https://github.com/JedWatson/react-select/issues/899 Can clients learn their time zone on a network configured using RA? Cannot Read Property 'top' Of Undefined Scroll Skip to content Ignore Learn more Please note that GitHub no longer supports old versions of Firefox. Cannot Read Property 'top' Of Undefined Angular How to be Recommended to be a Sitecore MVP How to decide between PCA and logistic regression?

Here following is code of Jquery.How can this will be fixed. $(document).ready(function($){$('a[href^="#"]').bind('click.smoothscroll',function (e) {e.preventDefault(); var target = this.hash,$target = $(target); $('html, body').stop().animate({'scrollTop': $target.offset().top}, 900, 'swing', function () {window.location.hash = target;});}); }); weblink You signed in with another tab or window. maoosi commented Jun 15, 2015 Because :nth-of-type selector is attached to a particular type, so if we don't want to use the same tag type (something different from a

like Terms Privacy Security Status Help You can't perform that action at this time. Uncaught Typeerror: Cannot Read Property 'top' Of Null

Underbrace under nested square roots Where do I drop off a foot passenger in Calais (P&O)? current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. When booking a cruise, how can I find a list of all the fees in advance? navigate here How do fonts work in LaTeX?

Why there are no approximation algorithms for SAT and other decision problems? Cannot Read Property 'top' Of Undefined Datetimepicker Are you sure it exists in the DOM? –Terry Nov 13 '14 at 2:30 No, in fact it doesn't exist on some pages, but the script is called on Log in or register to post comments Add child issue, clone issue News itemsDrupal news Planet Drupal Association news Social media directory Security announcements Jobs Our communityCommunity Getting involved Services, Training

Appreciate the help –tigre Nov 13 '14 at 17:02 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote You can use the console.log() function to actually

Inequality caused by float inaccuracy Does f:x mean the same thing as f(x)? Reload to refresh your session. Is adding the ‘tbl’ prefix to table names really a problem? Cannot Read Property 'offset' Of Undefined I always had the element in place which was a

tag.

How do I handle this? The error is: "cannot read property 'top' of undefined" The error is at var stickyNavTop = $('.toc').offset().top - 222; and it is preventing other js to work properly. And what a simple solution. his comment is here If an image is rotated losslessly, why does the file size change?

Already have an account? Browse other questions tagged javascript jquery scroll undefined offset or ask your own question. Seeing as this solution is not addressed at all in this thread, I'll add it. We recommend upgrading to the latest Safari, Google Chrome, or Firefox.

Remember, if you immediately call your javascript before the document is ready then elements requiring an element from the document might find an undefined value. function showTop(el) { var page = document.getElementById(el); var height = page.offsetTop; alert(height); }

share|improve this answer answered May 26 at 9:55 Shrabanee Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Thanks for reporting!

You signed out in another tab or window. Solved it by replacing css selector used on smartscroll.js, line 106: replace :nth-of-type by :nth-child @d4nyll is there any particular reason you used :nth-of-type ? You signed out in another tab or window. Would we find alien music meaningful?

addFieldToFilter() And Condition in magento2 Why is this C++ code faster than my hand-written assembly for testing the Collatz conjecture? smartscroll owner d4nyll commented May 14, 2015 I took a look at your markup. Reload to refresh your session. I tested it in 1.3 and the only problem is it has no style as mentioned above.

This may be a problem related to React in Meteor 1.2. more hot questions question feed default about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation I'm still new to jQuery. It is very likely that this javascript function was placed before the actual html was loaded.

Example page using script Script: // Sidebar Nav Sticky with Scroll jQuery(document).ready(function() { var stickyNavTop = $('.toc').offset().top - 222; var stickyEnd = $('.content').height() - 111; // stores height of .content element Did a thief think he could conceal his identity from security cameras by putting lemon juice on his face? You signed in with another tab or window.