$(".text").(mCustomScrollbar({
theme:"dark-thin",
advanced:{
autoScrollOnFocus:false,
updateOnContentResize:true,
updateOnBrowserResize:true
}
});我有页面使用mCustomScrollbar &这个页面也使用jquery ,将另一个页面加载到其中。我的问题是如何为每个类型设置委托mCustomScrollbar?
发布于 2014-02-07 04:26:39
使用滚动条将所有想要的元素放在同一个类中,然后将您拥有的代码放在外部.js文件中。
应该是这样的:
$(document).ready(function() {
$(".text").delegate("click", function({
$(this).mCustomScrollbar({
theme:"dark-thin",
advanced:{
autoScrollOnFocus:false,
updateOnContentResize:true,
updateOnBrowserResize:true
}
});
});
});然后将.js脚本加载到父页面(使用jquery.load的脚本),如下所示:
<script src="blabla.js"></script>注意:如果您使用的是jQuery 1.7+,请使用.on()而不是委托()。
发布于 2014-02-16 15:49:31
mCustomScrollbar总是调用http://ajax.googleapis.com/
如果搜索jquery.mCustomScrollbar.concat.min.js,您将看到:
<script src="'+a+'//指的是
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>因此,您需要在每个类型中调用上面的脚本(diret到http://ajax.googleapis.com/)
因为jquery.mCustomScrollbar.concat.min.js在他们的脚本中调用了另一个jquery
您需要添加另一个调用下面函数的外部js。
$("***your class or your id***").mCustomScrollbar({theme:"dark-thin"});并调用您的外部js函数,您希望使用这个自定义滚动条。
样本:
我在html的多个div中使用了这个自定义滚动条。
所以我写了外部js (例如: ayam.js)
函数content1 () { $(".content1").mCustomScrollbar({theme:"dark-thin"});}
所以每一个我称之为onclick=的div都是“content1”
对不起,我的英语很差,我来自印度尼西亚:)谢谢
https://stackoverflow.com/questions/21619294
复制相似问题