零散杂记

function getElement(selector) {
  this.style = document.querySelecotrAll(selector).style;
}
 
getElement.prototype.color = function(color) {
  this.style.color = color;
  return this;
}
getElement.prototype.background = function(bg) {
  this.style.backgroundColor = bg;
  return this;
}
getElement.prototype.fontSize = function(size) {
  this.style.fontSize = size;
  return this;
}
 
//调用
var el = new getElement('#id')
el.color('red').background('pink').fontSize('12px');

原文地址:https://www.cnblogs.com/kekang/p/5648964.html