0

在我的 gsp 中,我有以下代码。

$ = jQuery.noConflict();
      j$(function($){
          j$(document).ready(function(){
              j$('#news-container').vTicker({
                  speed: 500,
                  pause: 3000,
                  animation: 'fade',
                  mousePause: true,
                  showItems: 1
              });
              j$(document).keydown(function(event) {
                  $("#helpLinkId").hide();
              });
          });
      })(jQuery);

运行时,它会给出类似未捕获的 TypeError: object is not a function(匿名函数)。解决方案是什么?

4

1 回答 1

1

您正在分配jQuery$而不是j$稍后您j$用于引用 jQuery,但j$没有分配给它的值

它应该是

// instead of assigning jQuery to $ you need to assign it to j$
j$ = jQuery.noConflict();
j$(function($) {
    j$(document).ready(function() {
        j$('#news-container').vTicker({
            speed : 500,
            pause : 3000,
            animation : 'fade',
            mousePause : true,
            showItems : 1
        });
        j$(document).keydown(function(event) {
            $("#helpLinkId").hide();
        });
    });
});//there is no need to pass jQuery here
于 2013-08-27T06:56:54.013 回答