Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
Share
LinkBack Thread Tools
Old 02-14-2013, 12:04 AM   #1
Warrior Member
 
Join Date: Feb 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
Old 02-14-2013, 01:18 AM   #2
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: May 2004
Location: Perth, Australia.
Posts: 740
Thanks: 5
Thanked 190 Times in 142 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
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
Old 02-14-2013, 03:12 AM   #3
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: Nov 2011
Location: Spain
Posts: 735
Thanks: 97
Thanked 198 Times in 171 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
Default Re: how to fix uncaught typeError: cannot read property 'top' of null ?

Give me the URL please.

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

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

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 07:49 PM.