当我尝试使用可滚动时,出现错误:$(".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/