[JS]让原生JS支持JQ CSS语句

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;
};

你可能感兴趣的:(HTML)