jQuery方法

/** 静态方法和实例方法:
 *     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');
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值