<script type="text/javascript">
//一个面向对象的JS例子,很好的支持了开闭原则
function HtmlControl(options) {//定义一个方法
var el = options.element;
el.style.width = options.width;
el.style.height = options.height;
el.style.top = options.top;
el.style.background = options.background;
}
var option = { //为方法定义一个参数对象
element: document.getElementById('test'),
left: 50,
top: 0,
100,
height: 200,
background: '#f00'
}
option.background = '#ff0'; //对参数对象进行扩展
HtmlControl(option); //调用
</script>