jquery - $ (".scrollable").scrollable 不是函数

标签 jquery jquery-tools

当我尝试使用可滚动时,出现错误:$(".scrollable").scrollable 不是一个函数

<html>
<head>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
</head>
<body>
<script>
$(function() {
  // initialize scrollable with mousewheel support
  $(".scrollable").scrollable({ vertical: true, mousewheel: true });
});
</script>
</body>
</html>

谁能看出是什么原因造成的?

[编辑]

在 Mark Hildreth 指出我使用的库已经捆绑了 jQuery 之后,我删除了我的 Google jQuery CDN 引用(上面未显示),然后我收到了“$ 不是函数”错误。

当时我知道 jQuery 与 flowplay 发生冲突,所以我更新了我的页面以使用

jQuery.noConflict();
jQuery(document).ready(function()){
   // jQuery('#foo) .... etc
});

这有点烦人,因为我必须更改现有页面中的脚本以使用 jQuery 而不是 $。

我可以继续使用 $,还是必须使用 jQuery?

最佳答案

// you don't have to use jQuery(document).ready(function()){});
// or noConflict

$ = null; // doean't matter here what happens to $

// just wrap your jQuery code passing in jQuery...
(function ($) {
    //write jQuery here...
    $(".scrollable").scrollable({
        vertical: true,
        mousewheel: true
    });
})(jQuery);

关于jquery - $ (".scrollable").scrollable 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5291486/

相关文章:

javascript - jQuery 偏移量为 <span> 或内联 <div> 返回无效值

javascript - 动态循环 JSON 并在设定的时间间隔后显示和隐藏对象元素

javascript - 如果子复选框被选中,jQuery 检查父复选框

javascript - jQuery 工具 -> 工具提示销毁方法?

javascript - 如何正确初始化单个项目的 jQuery 工具的可滚动组件?

javascript - 将参数传递给 jQuery 函数

JQUERY工具: is it possible to expose two elements?

javascript - 在javascript中关闭弹出窗口后如何刷新父页面?

JQuery 工具选项卡与 JQuery UI 冲突

jquery - jQuery 如何让返回值看起来像一个数组?