- 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
廣告