jquery 判断控件css样式,如何使用jQuery获取所有元素css属性的列表?

复制源自

SO1004475 – jQuery CSS plugin that returns computed style of element to pseudo clone that element? – 请按照链接和upvote那里,如果你发现它有用.

这似乎是可笑的,但这可能是你最好的选择 – 使.css()没有任何参数得到一个对象与所有这些东西设置.

jQuery.fn.css = (function(css2) {

return function() {

if (arguments.length) { return css2.apply(this,arguments); }

var attr = ['font-family','font-size','font-weight','font-style','color','text-transform','text-decoration','letter-spacing','word-spacing','line-height','text-align','vertical-align','direction','background-color','background-image','background-repeat','background-position','background-attachment','opacity','width','height','top','right','bottom','left','margin-top','margin-right','margin-bottom','margin-left','padding-top','padding-right','padding-bottom','padding-left','border-top-width','border-right-width','border-bottom-width','border-left-width','border-top-color','border-right-color','border-bottom-color','border-left-color','border-top-style','border-right-style','border-bottom-style','border-left-style','position','display','visibility','z-index','overflow-x','overflow-y','white-space','clip','float','clear','cursor','list-style-image','list-style-position','list-style-type','marker-offset'];

var len = attr.length,obj = {};

for (var i = 0; i < len; i++) {

obj[attr[i]] = css2.call(this,attr[i]);

}

return obj;

};

})(jQuery.fn.css);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值