jScrollPane滚动条问题
我正在开发一个使用 Wordpress 作为 CMS 的网站,并且我想在我的网站的 div 内使用自定义滚动条。我一直在尝试使用 jScrollPane 插件,但无法使其正常工作。
主要代码在我的 header.php 文件中,并且有一个类 .scroll-pane header.php 中的相关代码是:
<style type="text/css" id="page-css">
.scroll-pane
{
width: 100%;
height: 280px;
overflow: auto;
}
</style>
<script src="<?php bloginfo('template_url'); ?>/js/jquery-1.3.2.min.js"></script>
<link type="text/css" href="<?php bloginfo(template_url); ?>/style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="<?php bloginfo(template_url); ?>/js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php bloginfo(template_url); ?>/js/jquery.jscrollpane.min.js"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function()
{
$('.scroll-pane').jScrollPane({showArrows: true});
});
</script>
page.php:
< div id="sign-right">
< div class="newsBox-padding">
< div class="scroll-pane newsBox"> WP loop goes here </div></div>
CSS:
.newsBox{height:280px; overflow: auto;}
我收到以下错误(被 firebug 捕获):
" $(".scroll-pane").jScrollPane is not a function
$('.scroll-pane').jScrollPane({showArrows: true}); "
我认为问题出在因此我尝试了来自各种帖子和论坛的一系列建议,包括:
$function(){ jQuery('.scroll-pane').jScrollPane({showArrows: true});
$function(){ $('.scroll-pane').jScrollPane({showArrows: true}); });
我检查了所有对外部文件的引用,并确保类的名称相同,它们似乎都是正确的。我也有一个精通代码的朋友看过它,但无济于事。
我真的很感谢你的帮助!
I am working on a site using Wordpress as a CMS, and I wanted to use a custom scroll bar inside a div on my website. I've been trying to use the jScrollPane plugin, but I'm having trouble getting it to work.
the main code is in my header.php file, and there is a class .scroll-pane the relevant code in header.php is:
<style type="text/css" id="page-css">
.scroll-pane
{
width: 100%;
height: 280px;
overflow: auto;
}
</style>
<script src="<?php bloginfo('template_url'); ?>/js/jquery-1.3.2.min.js"></script>
<link type="text/css" href="<?php bloginfo(template_url); ?>/style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="<?php bloginfo(template_url); ?>/js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php bloginfo(template_url); ?>/js/jquery.jscrollpane.min.js"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function()
{
$('.scroll-pane').jScrollPane({showArrows: true});
});
</script>
page.php:
< div id="sign-right">
< div class="newsBox-padding">
< div class="scroll-pane newsBox"> WP loop goes here </div></div>
CSS:
.newsBox{height:280px; overflow: auto;}
I get the following error (caught with firebug):
" $(".scroll-pane").jScrollPane is not a function
$('.scroll-pane').jScrollPane({showArrows: true}); "
I think the problem is in the function so I've tried a bunch of suggestions from various posts and forums including:
$function(){ jQuery('.scroll-pane').jScrollPane({showArrows: true});
$function(){ $('.scroll-pane').jScrollPane({showArrows: true}); });
I've checked all of my references to external files and made sure classes were named the same, they all seem to be right. And I've had a code savvy friend look at it too, to no avail.
I really appreciate your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
也许我在这里遗漏了一些东西,从未使用过 jscrollpane,但我没有看到你包括 jquery 本身。此外,您还可以调用 noconflict ,然后仍然在函数中使用 $ 。
Maybe I'm missing something here, never used jscrollpane, but I don't see you including jquery itself. Also you call noconflict and then still use $ in your function.
我遇到这个问题是因为我加载了两次jquery。
Scrollpane 在以下情况下使用确实效果很好:
另外,不要忘记在您应用的 div 中指定宽度和高度; IE。
I've had this problem because I was loading twice jquery.
Scrollpane does indeed work well when used in:
Also don't forget to specify width and height in the div you're applying; ie.
我没有看到您包含最新的 jQuery,请尝试添加它。
要使用 google 主机添加最新的 jQuery:
并尝试使用 Chrome 开发人员工具,然后使用资源选项卡,然后您将看到网络实际加载的 JS 文件。
你可以在我的博客上看到一篇关于这些滚动条的好文章: jQuery Scrollbars
同样像@kingjiv 所说,你使用 Conflict 然后使用 '$'。
尝试消除冲突并仅使用:
如果仍然不起作用,则 jScrollPane 会在 jQuery 之前加载。
要解决此问题,请尝试以下方法:
首先将您的 移动
到
结束标记之后的末尾。
如果仍然不起作用,请尝试使用当文档准备好时
它必须起作用:)
I dont see that you include the latest jQuery, try adding it.
To add the latest jQuery using google host:
And try using Chrome Developers Tools then Resources Tab, then you'll see which JS files the web actually loads.
you can see a nice post at my blog about those scroll bars: jQuery Scrollbars
Also like @kingjiv said, you use Conflict then '$'.
Try removing he Conflict and only use:
If it still doesn't work, the jScrollPane prolly loads before the jQuery does.
To fix this try those methods:
First moving you'r
To the end after the
</body>
Closing tag.If still doesn't work try using When document ready
It must work :)
我遇到了同样的问题,花了很长时间才解决。我只是找不到任何解决方案。
然后我遇到了这个
Wordpress
插件,名为:WP jScrollPane
。我下载并安装了它。按照说明进行操作,就会出现自定义
滚动条
。所以对我来说这实际上是一个非常简单的解决方案。我太喜欢那个脚本了,以至于我完全忘记了
Wordpress
也有自己的插件。无论如何,我不知道这对你是否有用,但它对我帮助很大。
I had the same problem and it took me ages to work it out. I just couldn't find any solution.
Then I came across this plugin for
Wordpress
named:WP jScrollPane
.I downloaded and installed it. Followed the instructions and the custom
scrollbar
appeared.So for me that was actually a very simple solution. I was so into that script, that I totally forgot that
Wordpress
has its own plugins as well.Anyway, I don't know if this is useful for you, but it helped me a lot.
我厌倦了这个插件的问题。我工作了一天才让它运行起来。我发现它需要:
... 文件才能正常运行。所以它是一个老插件并且支持不是很好。
我对我的问题有一个非常简单的解决方案:):
这
是工作示例:
http://jsfiddle.net/ghdcmsxx/
太棒了:D。它甚至针对触摸进行了优化。
哇。没有 jquery,只有很少的 css 和 html。我喜欢它。
I am tired of problems with this plugin. I worked for one day to get it to run. I found out, that it needs the:
... file, to run normally. So it is an old plugin and the support is not very good.
I have a very simple solution for my problem :) :
and
Here is the working example:
http://jsfiddle.net/ghdcmsxx/
That´s great :D . And it´s even optimized for touch.
Wow. No jquery, only litte css and html. I love it.