我使用的幻灯片需要mootools 1.11,而我的其他代码需要jQuery。不幸的是,我一调用jquery库,幻灯片就崩溃了。
我能把这个小jquery代码转换成moo工具或纯javascript吗?mootools代码会是什么样子的?
jQuery(document).ready(function(jQuery) {
jQuery('.rgstitle, .rgsdescription').click(function(event) {
window.open(jQuery('#rgslideshow-4574 a img:visible').parent().attr('href'), '_self');
return false;
});
});非常感谢!
发布于 2012-03-07 17:21:33
让你基于mootools的代码的'$‘保持原样。并使用'jQueryDollar‘作为您的jQuery代码。添加jquery库后,使用以下命令:
<script src="jquery.js"></script>
<script>
var jQueryDollar = jQuery.noConflict();
// Do something with 'jQueryDollar'
jQueryDollar(document).ready(function(jQueryDollar) {
jQueryDollar('.rgstitle, .rgsdescription').click(function(event) {
window.open(jQueryDollar('#rgslideshow-4574 a img:visible').parent().attr('href'), '_self');
return false;
});
});
</script>现在在下面添加mootools库:
<script src="mootools.js"></script>
<script>
//'$' is now free for mootools
</script>发布于 2012-03-07 15:43:32
如果你想让这两个库一起工作,这里有一个简单的解决方案。将以下内容放在jQuery.js脚本标记后面
<script type="text/javascript">
jQuery.noConflict();
</script>发布于 2013-11-24 10:34:26
Jquery团队的一篇Avoiding Conflicts with Other Libraries文章说,你最好去看看。我得到了同样的问题,并解决了jQuery滑块和mootool新闻标记:D
https://stackoverflow.com/questions/9597442
复制相似问题