我尝试在一个页面中实现2个插件,当我介绍第二个插件时...第一个插件停止工作..你能帮我解决这个问题吗...他是我正在努力构建的页面.. < / p>
这是我试图使用的2个插件。
http://www.catswhocode.com/blog/how-to-integrate-a-slideshow-in-your-wordpress-theme
http://www.fyneworks.com/jquery/star-rating/
这是我的代码..评级脚本从一开始就在运行。我试图在此页面中添加此幻灯片,如
<link rel="stylesheet" href="testing/t1/css/layout.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="testing/t1/css/jd.gallery.css" type="text/css" media="screen" charset="utf-8" />
<script src="testing/t1/scripts/mootools.v1.11.js" type="text/javascript"></script>
<script src="testing/t1/scripts/jd.gallery.js" type="text/javascript"></script>
<script src="testing/t1/scripts/jd.gallery.transitions.js" type="text/javascript"></script>
<script type="text/javascript">
var newj = jQuery.noConflict();
function startGallery() {
var myGallery = new gallery(newj('myGallery'), {
timed: true,
showArrows: false,
embedLinks: false,
showCarousel: true,
defaultTransition: "continuoushorizontal"
});
} window.onDomReady(startGallery);
</script>
请帮我解决这个问题
答案 0 :(得分:3)
您正在使用Mootools和JQuery。这两个javascript库互相覆盖。
http://www.catswhocode.com/blog/how-to-integrate-a-slideshow-in-your-wordpress-theme使用Mootools http://www.fyneworks.com/jquery/star-rating/使用Jquery
您需要找到仅使用jquery或mootools的插件。参见:
了解每个框架的更多插件。
答案 1 :(得分:2)
所以第一个是MooTools,第二个是jQuery。你可以尝试做$ .noConflict()
http://api.jquery.com/jQuery.noConflict/
jQuery.noConflict();
function startGallery() {
var myGallery = new gallery($('myGallery'), {
timed: true,
showArrows: false,
embedLinks: false,
showCarousel: true,
defaultTransition: "continuoushorizontal"
});
} window.onDomReady(startGallery);
关于在您的网站上使用$ all,可以这样做(基于文档):
<script type="text/javascript" src="other_lib.js"></script><!-- your mootools lib-->
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
$('#id-here').click(function(e) {
alert('I can use $ here with no conflicts on other js libraries!');
});
});
// Code that uses other library's $ can follow here.
function startGallery() {
var myGallery = new gallery($('myGallery'), {
timed: true,
showArrows: false,
embedLinks: false,
showCarousel: true,
defaultTransition: "continuoushorizontal"
});
} window.onDomReady(startGallery);
</script>
如果这仍然不起作用,请花点时间阅读手册......你最终会得到它^^只知道使用.noConflict为我工作了一个类似的案例,我有一段时间了。
虽然我很好奇你的星级代码所在......