Jquery与jquery工具冲突 [英] Jquery conflict with jquery tools
问题描述
我的问题是在添加:
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
到我的网站,nivoslider等插件以及其他jquery脚本无效。
to my site, Plugins like nivoslider, and other jquery scripts are not working.
但是为了使下面的代码能够工作,我需要jquery tools
but in order to make working the code below i need "jquery tools"
<script type="text/javascript"><!--
function GetAvailProductSizes() {
$('select#productsize option').remove();
$('select#productsize').append('<option value=""><? echo $langdata['oneprodpage_selectsize']; ?>...</option>');
var color = $('#productcolor').val();
if (color > 0) {
var availsizes;
var http_request = new XMLHttpRequest();
http_request.open( "GET", '<? echo ROOT; ?>/autocompleteavailsizes/?productid=<? echo $thisproduct['id']; ?>&color=' + color, true );
http_request.send(null);
http_request.onreadystatechange = function () {
if ( http_request.readyState == 4 ) {
if ( http_request.status == 200 ) {
availsizes = eval( "(" + http_request.responseText + ")" );
for (var i = 0; i < availsizes.length; i++) {
$('select#productsize').append('<option value="' + availsizes[i].id + '">' + availsizes[i].name + '</option>');
};
} else {
alert( "There was a problem with the URL." );
}
http_request = null;
}
};
};
}
//-->
</script>
仅当我包含时才有效:
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
但如果我这样做,其他jquery脚本无效,我的意思是nivoslider和其他简单的popup div ...
BUT if i do so, other jquery scripts are not working, i mean nivoslider and other simple popup divs...
我应该如何解决这个问题?
How should i solve this problem?
推荐答案
jQuery Tools包含它自己的jQuery版本。包含一个不包含它自己的jQuery的jQuery工具版本。 http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js
jQuery Tools includes it's own version of jQuery. Include a version of jQuery tools that doesn't include it's own jQuery. http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js
确保首先包含您的其他jquery,然后是jquery工具,然后是其余的。
Make sure you include your other jquery first, followed by jquery tools, and then the rest.
<script src="jquery.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js"></script>
<script src="nivoslider.js"></script>
...
这篇关于Jquery与jquery工具冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!