blob: 20b3d4485065f37ce0dd5c364db6369d082e8c9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<html>
<head>
<title>setAttribute() Test</title>
<style type="text/css" title="text/css">
p { display:none; color: red; }
p[title] { display:block; color: green; }
p[id] { display:block; color: green; }
p[class] { display:block; color: green; }
p[lang] { display:block; color: green; }
</style>
<script type="text/javascript">
window.onload = init;
function init()
{
document.getElementsByTagName('p')[0].setAttribute('class','test');
document.getElementsByTagName('p')[1].setAttribute('id','test');
document.getElementsByTagName('p')[2].setAttribute('title','This is a test');
document.getElementsByTagName('p')[4].setAttribute('lang','en');
}
</script>
</head>
<body>
<h1>setAttribute() Test</h1>
<p>
This element's Class attribute is set using setAttribute(). It should be green.
</p>
<p>
This element's ID attribute is set using setAttribute(). It should be green.
</p>
<p>
This element's Title attribute is set using setAttribute(). It should be green.
</p>
<p title="This is hard-coded">
This element's Title attribute is hard-coded. It should be green.
</p>
<p>
This element's Lang attribute is set using setAttribute(). It should be green.
</p>
</body>
</html>
|