- Prototype 教程
- Prototype - 主页
- Prototype - 简要概览
- Prototype - 有用特性
- Prototype - 工具方法
- Prototype - 元素对象
- Prototype - 数字处理
- Prototype - 字符串处理
- Prototype - 数组处理
- Prototype - Hash 处理
- Prototype - 基本对象
- Prototype - 模板
- Prototype - 枚举
- Prototype - 事件处理
- Prototype - 窗体管理
- Prototype - JSON 支持
- Prototype - AJAX 支持
- Prototype - 表达范围
- Prototype - 定期执行
- Prototype 有用资源
- Prototype - 快速指南
- Prototype - 有用资源
- Prototype - 讨论
Prototype - setStyle() 方法
此方法修改元素的 CSS 样式属性。样式作为属性值对的哈希值传递,其中属性以其大写形式指定。
语法
element.setStyle(styles);
返回值
返回一个 HTML 元素。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function setColor() {
$('test').setStyle({
backgroundColor: '#900',
fontSize: '12px'
});
}
</script>
</head>
<body">
<p id = "test">Click the button to see the result.</p>
<input type = "button" value = "Click" onclick = "setColor();"/>
</body>
</html>
输出
prototype_element_object.htm
广告