我做了一些 Jquery,你可以在下面看到这个小提琴:http: //madaxedesign.co.uk/dev/Test/ http://jsfiddle.net/x82mU/1/
代码:
$(document).ready(function() {
var $root = $('html, body ');
$('.scroll a').click(function(e) {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});
// Responsive menu
$(function() {
var pull = $('#pull'),
menu = $('nav ul'),
menuHeight = menu.height()
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function(){
var w = $(window).width();
if(w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
});
但它解决了这个错误:Uncaught TypeError: Cannot read property 'top' of undefined
这阻止了我的下一个 Jquery 工作。
我想知道是否有人可以让我知道为什么,或者给我一个解决方案?
非常感谢