---
title: "通过javascript设置CSS辅助类"
author: "fkshl"
date: "2012-08-12T10:04:05Z"
tags: []
categories: ["Web前端"]
slug: "javascript-css"
draft: false
lastmod: "2012-08-12T10:04:05Z"
id: 1629458
url: "https://fkshl.iteye.com/blog/1629458"
---

```javascript

var css = {};
css.util = {
	setStyle : function(el, prop, val) {
		document.getElementById(el[i]).style[prop] = val
	},
	setCss : function(el, style) {
		for ( var prop in style) {
			if (!style.hasOwnProperty(prop))
				continue;
			css.util.setStyle(el, prop, style[prop]);
		}
	}
}

```