-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathcolor.html
More file actions
25 lines (23 loc) · 1012 Bytes
/
Copy pathcolor.html
File metadata and controls
25 lines (23 loc) · 1012 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>select color</title>
</head>
<body>
<input type="color" name="color" id="color" onchange="changeColor()"> //选择颜色的标签,type="color"
<span id="colorInfo"></span>
</body>
<script type="text/javascript">
var color = document.getElementById("color"); //通过使用 getElementById() 来访问 <color> 元素
var colorInfo = document.getElementById("colorInfo");
colorInfo.style.color = color.value; //给<span>的字体加颜色
colorInfo.innerHTML = color.value; //给<span>加内容(<color>的值)
function changeColor(){ //改变颜色的事件
colorInfo.style.color = color.value;
colorInfo.innerHTML = color.value;
}
let a = { name: 'zhangsan' }
console.log(a.value)
</script>
</html>