jQuery single page navigation

I've created [this][1] script and I want to use it for website navigation in my project. As my knowledge of jQuery is quite poor, I'm not sure that code is correct and enough optimized. Could you help me to find out if there are any ways to optimize the code, and indicate mistakes I've made? [1]: http://jsfiddle.net/Cone/fAz7p/1/ $(function () { $("li a").click(function () { var liC = $(this).attr("href"); var liD = $("#" + liC).offset().top; $("html, body").stop().animate({ scrollTop: liD }, 'slow'); return false; }); $(window).scroll(function () { $('.dober').each(function () { var hRt = $(this).attr('id'); if ($(this).offset().top <= $(window).scrollTop()) { $('li a').css({ padding: 0 }); $('a[href=' + hRt + ']').css({ padding: 10 }); } else { $('a[href=' + hRt + ']').css({ padding: 0 }); } }); }); });
Is it actually working right now? If so, the question would be better for codereview.stackexchange.com.

以上就是jQuery single page navigation的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏