谢谢帮忙分析一下,jquery 里面有一个ui.js文件这么写的意思是什么吗? 为什么(function(){})(jquery) 后面这个jquery变量是什么作用啊?
(function($) {
/*
* Rotate
*/
$.extend($.ui.tabs.prototype, {
rotation: null,
rotate: function(ms) {
var self = this;
function stop(e) {
if (e.clientX) { // only in case of a true click
clearInterval(self.rotation);
}
}
// start interval
if (ms) {
var t = this.options.selected;
this.rotation = setInterval(function() {
t = ++t < self.$tabs.length ? t : 0;
self.select(t);
}, ms);
this.$tabs.bind(this.options.event, stop);
}
// stop interval
else {
clearInterval(this.rotation);
this.$tabs.unbind(this.options.event, stop);
}
}
});
})(jQuery);
(function () {})();这样就是调用它,
这是定义一个js匿名函数并执行,给它传jQuery的js变量嘛,
jQuery框架只有一个全局变量也就叫jQuery
function($) {
//....
} 这样就是定义一个js匿名函数,要传一个参数
(function($) {
//....
})(jQuery);这样就是执行这个js匿名函数,
相当于
var noname = function($) {
//....
};
noname(jQuery);