-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hello15.html
63 lines (54 loc) · 1.68 KB
/
Hello15.html
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
input{
width: 60px;
height: 60px;
}
#toblack{
background-color: black;
}
#towhite{
background-color: white;
}
#togreen{
background-color: green;
}
</style>
</head>
<body id="">
<input type="button" id="black" value="黑色" style=";" />
<input type="button" id="white" value="白色" style=";" />
<input type="button" id="green" value="绿色" style=";" />
<script type="text/javascript">
var btnBlack = document.getElementById('black');
var btnWhit = document.getElementById('white');
var btnGreen = document.getElementById('green');
btnBlack.addEventListener('click',setBlack);
btnWhit.addEventListener('click',setWhite);
btnGreen.addEventListener('click',setGreen);
function setBlack(){
document.body.id = "toblack";
var id=document.body.id;
localStblack.setItem('getId',id);
}
function setWhite(){
document.body.id = "towhite";
var id=document.body.id;
localStwhite.setItem('getId',id);
}
function setGreen(){
document.body.id = "togreen";
var id=document.body.id;
localStgreen.setItem('getId',id);
}
var curId = localStwhite.getItem('getId');
if(curId != null){
document.body.id = curId;
}
</script>
</body>
</html>