返回到:Prototype – 元素对象
此方法修改元素的 CSS 样式属性。样式作为属性值对的散列传递,其中属性以驼峰形式指定。
语法
element.setStyle(styles);
返回值
返回一个 HTML 元素。
例子
HTML
x
20
20
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function setColor() {
8
$('test').setStyle({
9
backgroundColor: '#900',
10
fontSize: '12px'
11
});
12
}
13
</script>
14
</head>
15
16
<body">
17
<p id = "test">Click the button to see the result.</p>
18
<input type = "button" value = "Click" onclick = "setColor();"/>
19
</body>
20
</html>
返回到:Prototype – 元素对象
阅读剩余 29%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9004.html