/** 静态方法和实例方法:
* 1.直接添加给类的是静态方法
* 2.通过类的实例调用的是实例方法
*/
function classCustom() {
}
classCustom.staticMethod = function () { //添加静态方法
alert("run staticMethod");
};
classCustom.prototype.instanceMethod = function () { //添加实例方法
alert("run instanceMethod");
};
/** each()方法:
* $(selector).each(function(index,element));
* index,可选,索引
* element,可选,元素
* 静态方法
* 可遍历伪数组
* 返回所遍历的对象
*/
/** map()方法:
* .map(callback(index,domElement))
* index,索引
* domElement,DOM元素
* 静态方法
* 可遍历伪数组
* 通过return返回新数组
*/
$(':checkbox').map(function () {
return this.id;
});
/** trim()方法
* $.trim(String);
* 静态方法
* 1.去除字符串两端的空白字符
* 2.不改变原字符串,结果返回一个新字符串
*/
var str = ' hello world ';
console.log('---' + str + '---'); //--- hello world ---
var result = $.trim(str);
console.log('---' + result + '---'); //---hello world---
/** isWindow()
* $.isWindow(Object);
* 判断Object是否是window对象
* 返回布尔值
*/
var w = window;
var result = $.isWindow(w);
console.log(result); //true
/** isArray()
* $.isArray(Object);
* 静态方法
* 判断Object是否为数组
* 返回值为布尔值
*/
var arr = [];
var str = '';
console.log($.isArray(arr)); //true
console.log($.isArray(str)); //false
/** isFunction
* $.isFunction(Object);
* 静态方法
* 判断Object是否为函数
* 返回值为布尔值
* jQuery 1.3之后的版本,例如在 Internet Explorer 中,由浏览器提供的函数alert(),以及 DOM 元素方法(比如 getAttribute())将不被认为是函数
*/
function func() {
alert("hello");
}
console.log($.isFunction(func)); //true
/** holdReady()
* $.holdReady(para);
* para为布尔值
* 静态方法
* 作用为暂停ready执行
*/
$.holdReady(true);
$(document).ready(function () {
alert('hello');
});