[英]2 javascripts plugin not working together
我试图在一个页面中实现2个插件,当我介绍第二个插件时...第一个插件停止工作..您能在这方面帮助我吗..他是我要构建的页面..
这是我要使用的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>
请帮我解决这个问题
您同时使用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的插件。 看到:
对于每个框架更多的插件。
所以第一个是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);
关于您在整个网站上使用$,可以做到这一点(基于文档):
<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在一段时间后的类似情况下对我有用。
虽然我很好奇您的星级代码在哪里...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.