質問編集履歴

3

コード変更

2020/02/07 14:12

投稿

unity.hatu
unity.hatu

スコア18

test CHANGED
File without changes
test CHANGED
@@ -102,10 +102,6 @@
102
102
 
103
103
  var valbrightness = document.getElementById("brightness").value;
104
104
 
105
- var elementReference = document.getElementById( "brightness" );
106
-
107
- var values = elementReference.value;
108
-
109
105
  img.style.webkitFilter = "brightness(" + valbrightness + ")";
110
106
 
111
107
  }
@@ -115,10 +111,6 @@
115
111
  function valueContrast() {
116
112
 
117
113
  var valcontrast = document.getElementById("contrast").value;
118
-
119
- var elementReference = document.getElementById( "contrast" );
120
-
121
- var values = elementReference.value;
122
114
 
123
115
  img.style.webkitFilter = "contrast(" + valcontrast + ")";
124
116
 

2

コード変更

2020/02/07 14:12

投稿

unity.hatu
unity.hatu

スコア18

test CHANGED
File without changes
test CHANGED
@@ -98,40 +98,6 @@
98
98
 
99
99
 
100
100
 
101
- function efectbton() {
102
-
103
- efe1 = document.efectbt.defo.checked;
104
-
105
- efe2 = document.efectbt.mono.checked;
106
-
107
- efe3 = document.efectbt.sepi.checked;
108
-
109
-
110
-
111
- var pic = document.getElementById('pic');
112
-
113
- if (efe1 == true) {
114
-
115
- pic.style.webkitFilter = "grayscale(0)";
116
-
117
- }
118
-
119
- else if (efe2 == true) {
120
-
121
- pic.style.webkitFilter = "grayscale(100)";
122
-
123
- }
124
-
125
- else if (efe3 == true) {
126
-
127
- pic.style.webkitFilter = "sepia(100)";
128
-
129
- }
130
-
131
- }
132
-
133
-
134
-
135
101
  function valueBrightness() {
136
102
 
137
103
  var valbrightness = document.getElementById("brightness").value;

1

誤字

2020/02/07 14:10

投稿

unity.hatu
unity.hatu

スコア18

test CHANGED
File without changes
test CHANGED
@@ -16,13 +16,33 @@
16
16
 
17
17
  ``` html
18
18
 
19
+ <!DOCTYPE html><html>
20
+
21
+ <head>
22
+
23
+ <meta charset="UTF-8">
24
+
25
+ <meta name="viewport" content="width=device-width" />
26
+
27
+ <title>cbk ji</title>
28
+
29
+ <link rel="stylesheet" href="style.css" />
30
+
31
+ </head>
32
+
33
+ <body>
34
+
35
+ <img src="img/test.png" id="pic">
36
+
37
+
38
+
19
39
  <div class="test">
20
40
 
21
41
  <p>輝度</p>
22
42
 
23
43
  <div id="sampleOutput" class="values">1</div>
24
44
 
25
- <input type="range" value="1" min="0" max="4" step="0.1" id="brightness" onmousemove="valueBrightness()" onchange="valueBrightness()"></p>
45
+ <input type="range" value="1" min="0" max="4" step="0.1" id="brightness" onmousemove="valueBrightness()" onchange="valueBrightness()">
26
46
 
27
47
  </div>
28
48
 
@@ -32,15 +52,85 @@
32
52
 
33
53
  <p>コントラスト</p>
34
54
 
35
- <div id="outputContrast" class="values">1</div>
55
+ <div id="contrastOutput" class="values">1</div>
36
56
 
37
- <input type="range" value="1" min="0" max="10" step="0.1" id="contrast" onmousemove="valueContrast()" onchange="valueContrast()"></p>
57
+ <input type="range" value="1" min="0" max="10" step="0.1" id="contrast" onmousemove="valueContrast()" onchange="valueContrast()">
38
58
 
39
59
  </div>
60
+
61
+ <script src="script.js"></script>
62
+
63
+ </body>
64
+
65
+ </html>
40
66
 
41
67
  ```
42
68
 
43
69
  ```javascript
70
+
71
+
72
+
73
+ var elem = document.getElementsByClassName('test');
74
+
75
+   var rangeValue = function (elem, target) {
76
+
77
+     return function(evt){
78
+
79
+       target.innerHTML = elem.value;
80
+
81
+    }
82
+
83
+   }
84
+
85
+   for(var i = 0, max = elem.length; i < max; i++){
86
+
87
+    bar = elem[i].getElementsByTagName('input')[0];
88
+
89
+    target = elem[i].getElementsByTagName('div')[0];
90
+
91
+     bar.addEventListener('input', rangeValue(bar, target));
92
+
93
+   }
94
+
95
+
96
+
97
+ var img = document.getElementById("pic");
98
+
99
+
100
+
101
+ function efectbton() {
102
+
103
+ efe1 = document.efectbt.defo.checked;
104
+
105
+ efe2 = document.efectbt.mono.checked;
106
+
107
+ efe3 = document.efectbt.sepi.checked;
108
+
109
+
110
+
111
+ var pic = document.getElementById('pic');
112
+
113
+ if (efe1 == true) {
114
+
115
+ pic.style.webkitFilter = "grayscale(0)";
116
+
117
+ }
118
+
119
+ else if (efe2 == true) {
120
+
121
+ pic.style.webkitFilter = "grayscale(100)";
122
+
123
+ }
124
+
125
+ else if (efe3 == true) {
126
+
127
+ pic.style.webkitFilter = "sepia(100)";
128
+
129
+ }
130
+
131
+ }
132
+
133
+
44
134
 
45
135
  function valueBrightness() {
46
136
 
@@ -49,8 +139,6 @@
49
139
  var elementReference = document.getElementById( "brightness" );
50
140
 
51
141
  var values = elementReference.value;
52
-
53
- document.getElementById( "sampleOutput" ).innerHTML = values;
54
142
 
55
143
  img.style.webkitFilter = "brightness(" + valbrightness + ")";
56
144
 
@@ -66,10 +154,18 @@
66
154
 
67
155
  var values = elementReference.value;
68
156
 
69
- document.getElementById( "outputContrast" ).innerHTML = values;
70
-
71
157
  img.style.webkitFilter = "contrast(" + valcontrast + ")";
72
158
 
73
159
  }
74
160
 
161
+
162
+
75
163
  ```
164
+
165
+
166
+
167
+ ##追記
168
+
169
+ 修正依頼があったので全文表示しました。
170
+
171
+ また、ネットの情報をかき集めて頑張って作ったのでごちゃごちゃしているかも知れませんが御了承ください。(ここ省略できるよみたいなのがあれば教えていただければ幸いです。)