我正在使用这个插件 https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin ,
但是我的 jquery 版本是 1.4,所以我使用了 jQuery.noConflict()
因为有人说我可以通过这个使用任何版本的 jquery:
var jq10 = jQuery.noConflict();
但是当我尝试使用该插件时它不会工作,它也不会有错误,所以我不知道我的代码是否有误,或者即使使用 jQuery 它也无法工作.noConflict()
。有人有想法吗?这是我正在做的一个示例,非常简单但是它不起作用,或者没有任何错误给我提示
<html>
<input type="file" name="files[]" id="fileupload" multiple>
</html>
//This is my original version
<script language="javascript" type="text/javascript" src="/scripts/jquery-1.4.2.min.js"></script>
//This is the minimum version required of the plugin
<script type="text/javascript" src="/scripts/new_jquery/jquery-1.6.4.js"></script>
//These are the requirements for the plugin
<script language="javascript" type="text/javascript" src="/scripts/new_jquery/fileupload/js/vendor/jquery.ui.widget.js"></script>
<script language="javascript" type="text/javascript" src="/scripts/new_jquery/fileupload/js/jquery.iframe-transport.js"></script>
<script language="javascript" type="text/javascript" src="/scripts/new_jquery/fileupload/js/jquery.fileupload.js"></script>
$(document).ready( function() {
var jq10 = jQuery.noConflict();
jq10('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
console.log(data);
}
});
});
你看,我只是控制台记录了数据,但它不会返回任何带有 Firebug 的东西,不会有任何错误或任何提示给我发生了什么事。
最佳答案
试试这个:
jQuery.noConflict();
// Do something with jQuery
jQuery( "div p" ).hide();
// Do something with another library's $()
$( "content" ).style.display = "none";
所以,
var jq10 = jQuery.noConflict();
jq10(document).ready( function() {
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
console.log(data);
}
});
});
关于javascript - 我可以使用任何版本的 jquery 使用 jQuery.noConflict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22176571/