回答編集履歴
1
jQueryを使わないバージョンを追記
test
CHANGED
@@ -35,3 +35,33 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
### jQueryを使わないバージョン
|
42
|
+
|
43
|
+
```JavaScript
|
44
|
+
|
45
|
+
document.addEventListener("DOMContentLoaded", function() {
|
46
|
+
|
47
|
+
const password = document.querySelector("#password");
|
48
|
+
|
49
|
+
const passCheck = document.querySelector("#passcheck");
|
50
|
+
|
51
|
+
const doPassCheck = function () {
|
52
|
+
|
53
|
+
password.classList.toggle("Required", passCheck.checked);
|
54
|
+
|
55
|
+
password.readOnly = !passCheck.checked;
|
56
|
+
|
57
|
+
password.value = passCheck.checked ? "" : "**";
|
58
|
+
|
59
|
+
};
|
60
|
+
|
61
|
+
doPassCheck();
|
62
|
+
|
63
|
+
passCheck.addEventListener("change", doPassCheck);
|
64
|
+
|
65
|
+
});
|
66
|
+
|
67
|
+
```
|