这个JS的错误是什么?

时间:2013-09-15 19:25:34

标签: jquery

!function ($) {
//=================================== scroll  ===================================//

    $body.scrollspy({
      target: '#navbar-main',
      offset: navHeight
    })

    $window.on('load', function () {
      $body.scrollspy('refresh')
    })

    $('#navbar-main [href=#]').click(function (e) {
      e.preventDefault()
    })


});

1 个答案:

答案 0 :(得分:4)

您正在生成一个函数,但从不执行它。

!(function ($) {
//=================================== scroll  ===================================//

    $body.scrollspy({
      target: '#navbar-main',
      offset: navHeight
    })

    $window.on('load', function () {
      $body.scrollspy('refresh')
    })

    $('#navbar-main [href=#]').click(function (e) {
      e.preventDefault()
    })


})(jQuery); // <-- Execute the function