【问题标题】:Inserting customized Scroll Text插入自定义滚动文本
【发布时间】:2012-10-15 23:29:57
【问题描述】:

我已经下载并自定义了一个滚动条(带有文本),但我无法将它与我的网站集成。

基本上这是滚动条的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery custom scrollbar demo</title>

<!-- Custom scrollbars CSS -->
<link href="jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script src="jquery.mCustomScrollbar.js"></script>
<script>
(function($){
$(window).load(function(){
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
});
})(jQuery);
</script>
</head>

我需要用这个代码放入一个页面

<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/jquery.fancybox-1.3.4.css" type="text/css" media="all">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/jquery.easing.js"></script>
<script type="text/javascript" src="js/jquery.masonry.js"></script>
<script type="text/javascript" src="js/jquery.transform.js"></script>
<script type="text/javascript" src="js/jquery.animate-colors-min.js"></script>
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="js/forms.js"></script>
<script type="text/javascript" src="js/switcher.js"></script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript" src="js/sprites.js"></script>
<script type="text/javascript" src="js/googleMap.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>

它给出了一个错误:

$("#content_1").mCustomScrollbar is not a function

【问题讨论】:

  • 下载的滚动文本的文档是怎么说的?
  • 这里有manos.malihu.gr/jquery-custom-content-scroller他只讲了怎么实现,我没看到有什么冲突
  • 只是为了确定,有没有 id="content_1" 的元素,你仔细检查了所有的拼写?然后将文件放在js 目录中,并像&lt;script src="js/jquery.mCustomScrollbar.js"&gt;?? 一样包含它
  • 我想我明白了!我正在检查所有内容,然后将滚动代码放在已经存在的代码之前并且它正在工作!只是为了理解它,我在主页代码之后再次放置了滚动代码,但它不再起作用。有人可以解释为什么会这样吗?感谢死亡四月的支持 :)
  • 什么“滚动码”?你不能在导入它的声明之前使用一个函数/这个函数可能已经被你的代码覆盖了/无论出于什么原因插件都需要放在上面/...

标签: javascript css web integration


【解决方案1】:

您需要将“jquery.mCustomScrollbar.js”添加到页面。 和“jquery.mCustomScrollbar.css”得到相同的样式。

现在在第一行添加:

<link href="jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />

您必须在运行"$("#content_1").mCustomScrollbar()" 函数之前和在jquery 库之后添加jquery 自定义滚动条。

<script src="jquery.mCustomScrollbar.js"></script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 2010-10-11
    • 1970-01-01
    相关资源
    最近更新 更多