Freelancer.com

Go Back   Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming
Register Blogs Social Groups CalendarHelp Desk

Reply
LinkBack Thread Tools
Unread 14th February 2013, 01:04 AM   #1
Warrior Member
 
Join Date: 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to fix uncaught typeError: cannot read property 'top' of null ?

HelloFriends i have a jquery problem. whenever i tried to apply on click scroll script i got this error "uncaught typeError: cannot read property 'top' of null". 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;
});
});

});
Marshall23 is offline   Reply With Quote
Unread 14th February 2013, 02:18 AM   #2
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: 2004
Location: Perth, Australia.
Posts: 740
Thanks: 5
Thanked 190 Times in 142 Posts
Default Re: how to fix uncaught typeError: cannot read property 'top' of null ?

I guess from this error, that $target is not defined.. Might need to do some console debugging and see what it comes back with.

Hope this helps

bruce

Quote:
Originally Posted by Marshall23 View Post
HelloFriends i have a jquery problem. whenever i tried to apply on click scroll script i got this error "uncaught typeError: cannot read property 'top' of null". 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);

$('html, body').stop().animate({
'scrollTop': .offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});

});

--------------------------------------------------
Any man who reads too much and uses his own brain too little falls into lazy habits of thinking - Albert Einstein
Bruce Hearder is offline   Reply With Quote
Unread 14th February 2013, 04:12 AM   #3
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: 2011
Location: Rostock, Germany
Posts: 814
Thanks: 105
Thanked 220 Times in 190 Posts
Default Re: how to fix uncaught typeError: cannot read property 'top' of null ?

Give me the URL please.

HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is online now   Reply With Quote
Reply

  Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming

Bookmarks

Tags
fix, null, property, read, top, typeerror, uncaught

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:41 AM.