Jquery学习笔记 - 属性与CSS操作
属性操作:val / attr / removeAttr / prop / removeProp / addClass / removeClass / toggleClass
val组:有则取无则设,利用hooks->晚些再看~
attr组:添加使用hooks,删除使用ele.removeAttribute底层API
prop组:添加使用hooks,删除使用delete操作符 delete this[name]
class组:取出现有class,空格分隔多个类名 cur += newclass + “”,
toggle下 this.className?删除:添加
CSS操作:核心函数getStyle,主要是兼容性的支持
if(window.getComputedStyle) {getStyle = function()}
else if (document.documentElement.currentStyle) {.......} //兼容ie8
》window.getComputedStyle(ele, pseudo 伪类) 取得CSS计算后的值,但位置关系除外,只读类数组
》ele.currentStyle 取得计算前的值,对象形式,其余类似上一方法
》ele.style 可读可写,获取内联样式
》ele.getPropertyValue 获取属性名称,比如“float”“right”等
参考:http://www.cnblogs.com/chuaWeb/p/jquery-1-9-1-CSS.html