零散杂记

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');

posted @ 2016-07-07 09:52  追恋KG  阅读(94)  评论(0编辑  收藏  举报