Lightbox jquery无冲突问题
我正在尝试使用插件,但是jquery有一个冲突,我阅读了一些文章,找到了解决这个问题的方法,但是我没有运气实现它 这是我的密码: 参考资料:Lightbox jquery无冲突问题,lightbox,jquery,Lightbox,Jquery,我正在尝试使用插件,但是jquery有一个冲突,我阅读了一些文章,找到了解决这个问题的方法,但是我没有运气实现它 这是我的密码: 参考资料: <link href="Lightbox/css/lightbox.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="Lightbox/js/prototype.js"></script> <script typ
<link href="Lightbox/css/lightbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Lightbox/js/prototype.js"></script>
<script type="text/javascript" src="Lightbox/js/scriptaculous.js?load=effects,builder"> </script>
<script type="text/javascript" src="Lightbox/js/lightbox.js"></script>
脚本:
<script type="text/javascript">
jQuery.noConflict();
(function ($) {
$(document).ready(function () {
$("a[rel=lightbox[group1]]").live("click", function () {
$("a[rel^='lightbox[group1]']").lightbox();
return false;
});
});
})(jQuery);
</script>
jQuery.noConflict();
(函数($){
$(文档).ready(函数(){
$([a[rel=lightbox[group1]])。实时(“单击”,函数(){
$([rel^='lightbox[group1]']);
返回false;
});
});
})(jQuery);
任何帮助都将不胜感激
我正在使用jquery 1.5.2版本看起来一切正常,所以我认为jquery没有加载? 如果使用
jQuery
而不是$
不起作用,那么可能就是这种情况
如果你的站点标题中有jQuery脚本,你需要检查FireBug的网络控制台,看看它是否已加载——Google Chrome还有一个很好的网络监视器,你可以使用
您还可以使用一个而不是引入原型库来使用单个插件。您可以尝试使用jQuery对象而不是$:
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("a[rel=lightbox[group1]]").live("click", function () {
jQuery("a[rel^='lightbox[group1]']").lightbox();
return false;
});
});
</script>
jQuery(文档).ready(函数(){
jQuery(“a[rel=lightbox[group1]]”)。live(“单击”,函数(){
jQuery(“a[rel^='lightbox[group1]']”);
返回false;
});
});
为了防止jQuery和prototype之间的冲突,您必须放置jQuery.noConflict()代码>就在包含jQuery之后,在任何其他希望$
属于另一个库的代码之前。然后,完成此操作后,$
将不会映射到jQuery,它将被其他库使用
您没有展示如何包含jQuery。下面是for.noConflcit()
的示例:
$.noConflict();
jQuery(文档).ready(函数($){
//使用jQuery的$的代码如下所示。
});
//使用其他库的$的代码可以在这里找到。
在您的情况下,我认为您的代码如下所示:
<link href="Lightbox/css/lightbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Lightbox/js/prototype.js"></script>
<script type="text/javascript" src="Lightbox/js/scriptaculous.js?load=effects,builder"> </script>
<script type="text/javascript" src="Lightbox/js/lightbox.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
jQuery.noConflict();
(function ($) {
$(document).ready(function () {
$("a[rel=lightbox[group1]]").live("click", function () {
$("a[rel^='lightbox[group1]']").lightbox();
return false;
});
});
// other jQuery code that uses $ can go here
})(jQuery);
// other jQuery code that uses jQuery (but not $) can go here or in other script tags
</script>
jQuery.noConflict();
(函数($){
$(文档).ready(函数(){
$([a[rel=lightbox[group1]])。实时(“单击”,函数(){
$([rel^='lightbox[group1]']);
返回false;
});
});
//其他使用$的jQuery代码可以转到这里
})(jQuery);
//其他使用jQuery(而不是$)的jQuery代码可以放在这里或其他脚本标记中
与调用jQuery.noConflict()
相关的包含js文件的顺序至关重要。@Francis-I已将“$”更改为“jQuery”,但它也不起作用。jQuery是否已加载?从显示为已加载的脚本列表中,没有列出jQuery。@DotNetter发生了什么?你有js错误吗?你能把它添加到你的问题中吗?@Arnold-我没有得到任何错误,因为我需要使用我在这里提到的plupload上传器显示动态上传的图像
<link href="Lightbox/css/lightbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Lightbox/js/prototype.js"></script>
<script type="text/javascript" src="Lightbox/js/scriptaculous.js?load=effects,builder"> </script>
<script type="text/javascript" src="Lightbox/js/lightbox.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
jQuery.noConflict();
(function ($) {
$(document).ready(function () {
$("a[rel=lightbox[group1]]").live("click", function () {
$("a[rel^='lightbox[group1]']").lightbox();
return false;
});
});
// other jQuery code that uses $ can go here
})(jQuery);
// other jQuery code that uses jQuery (but not $) can go here or in other script tags
</script>