返回到:Prototype – 元素对象
此方法将 CSS 类添加到元素。
语法
element.addClassName(className);
返回值
添加了 CSS 类的 HTML 元素。
例子
HTML
x
29
29
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type="text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function addClass() {
8
node = $("firstDiv");
9
node.addClassName("title");
10
}
11
</script>
12
</head>
13
14
<style type = "text/css">
15
.title {
16
color:#36C;
17
font-size:20px;
18
}
19
</style>
20
21
<body>
22
<div id = "firstDiv">
23
<p>This is first paragraph</p>
24
</div>
25
<br />
26
27
<input type = "button" value = "Add Class" onclick = "addClass();"/>
28
</body>
29
</html>
返回到:Prototype – 元素对象
阅读剩余 43%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9157.html