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
64
65
66
67
68
69
70
71
|
<p>
<input type="hidden" id="hidden" value="hidden" /><br />
<input type="text" id="text" value="text" /><br />
<input type="search" id="search" value="search" /><br />
<input type="tel" id="tel" value="tel" /><br />
<input type="url" id="url" value="url" /><br />
<input type="email" id="email" value="email" /><br />
<input type="password" id="password" value="password" /><br />
<input type="date" id="date" value="date" /><br />
<input type="month" id="month" value="month" /><br />
<input type="week" id="week" value="week" /><br />
<input type="time" id="time" value="time" /><br />
<input type="datetime-local" id="datetime-local" value="datetime-local" /><br />
<input type="number" id="number" value="number" /><br />
<input type="range" id="range" value="range" /><br />
<input type="color" id="color" value="color" /><br />
<input type="checkbox" id="checkbox" value="checkbox" /><br />
<input type="radio" id="radio" value="radio" /><br />
<input type="file" id="file" value="file" /><br />
<input type="submit" id="submit" value="submit" /><br />
<input type="image" id="image" value="image" /><br />
<input type="reset" id="reset" value="reset" /><br />
<input type="button" id="button" value="button" /><br />
<input type="invalid" id="invalid" value="invalid" /><br />
</p>
<script>
var ids = [
"hidden",
"text",
"search",
"tel",
"url",
"email",
"password",
"date",
"month",
"week",
"time",
"datetime-local",
"number",
"range",
"color",
"checkbox",
"radio",
"file",
"submit",
"image",
"reset",
"button",
"invalid",
];
document.addEventListener("DOMContentLoaded", function() {
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var e = document.getElementById(id);
console.log("id=", id, "type=", e.type);
}
var e = document.getElementById("invalid");
e.type = "invalid2"
console.log("after change type=", e.type);
e.type = "number"
console.log("after change 2 type=", e.type);
e.value = "123abc456"
console.log("after value change value=", e.value);
});
</script>
|