HTMLElement.prototype.css = function () {
var option;
if (arguments.length > 0) {
option = arguments[0];
if (2 === arguments.length) {
option = {}, option[arguments[0]] = arguments[1];
}
if ('object' === typeof option) {
for (var key in option) {
if (option.hasOwnProperty(key)) {
this.style[key] = option[key];
}
}
}
}
return this;
};[JS]让原生JS支持JQ CSS语句
最新推荐文章于 2021-08-04 00:19:47 发布
本文介绍了一种在JavaScript中为HTMLElement原型添加自定义css方法的技术。该方法允许开发者通过传递对象参数来设置元素的样式属性,提高了代码的复用性和可读性。
1564

被折叠的 条评论
为什么被折叠?



