jquery access方法 有什么用

Jquery设置对象属性的有几种方法
1、获取属性attr(name)  
2、设置属性attr(name,value)
3、批量设置属性attr(properties)
4、为所有匹配的元素设置一个计算的属性值,由这个函数计算的值作为属性值。
attr(key, function(index, attr))
5、移除属性 removeAttr(name)

而这些方法的源码是这样的
jQuery.fn.extend({
attr: function( name, value ) {
return access( this, name, value, true, jQuery.attr );
})

返回的都是access的返回值,其实attr就是个传值的作用
那么access的意思就是 差不多入口的意思,它就是判断key.value的不同类型,最终会把值传递给jQuery的静态方法attr处理
posted @ 2015-10-19 18:41  jack_ou  阅读(515)  评论(0编辑  收藏  举报