如何使JQuery 1.8.3与其他JQuery库兼容
我有这个代码来调整图像的位置如何使JQuery 1.8.3与其他JQuery库兼容,jquery,conflict,Jquery,Conflict,我有这个代码来调整图像的位置 $(window).load(function() { center(); }); $(window).resize(function() { center(); }); function center() { var pos = $('#banner img').width() - $(window).width(); $('#banner img').css({ left
$(window).load(function() {
center();
});
$(window).resize(function() {
center();
});
function center() {
var pos = $('#banner img').width() - $(window).width();
$('#banner img').css({
left : pos / 2 * -1
});
}
我知道使用jQuery(函数($)不会与其他$(文档)冲突。在其他jQuery库中准备就绪。如何编写它以便$(窗口)。加载和调整大小不会冲突?限制也是版本1.8.3。谢谢。找到了它…绑定事件似乎太有效了
jQuery(window).on("load resize",function(e){
center();
});
function center() {
var pos = jQuery('#banner img').width() - jQuery(window).width();
jQuery('#banner img').css({
left : pos / 2 * -1
});
}