回答編集履歴
2
追記
test
CHANGED
@@ -81,3 +81,99 @@
|
|
81
81
|
</html>
|
82
82
|
|
83
83
|
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
また、もし jQuery で行わなければならないのであれば、以下のように行うことが出来ると思います([動作確認用リンク](https://codepen.io/anon/pen/gywKxo))。
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
```HTML
|
92
|
+
|
93
|
+
<!DOCTYPE html>
|
94
|
+
|
95
|
+
<html lang="ja">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<head>
|
100
|
+
|
101
|
+
<meta charset="UTF-8">
|
102
|
+
|
103
|
+
<title>タイトル</title>
|
104
|
+
|
105
|
+
<style>
|
106
|
+
|
107
|
+
.drop-upload {
|
108
|
+
|
109
|
+
border: 2px dotted #0B85A1;
|
110
|
+
|
111
|
+
color: #92AAB0;
|
112
|
+
|
113
|
+
text-align: left;
|
114
|
+
|
115
|
+
vertical-align: middle;
|
116
|
+
|
117
|
+
padding: 10px;
|
118
|
+
|
119
|
+
margin: 10px;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
.drop-upload input {
|
126
|
+
|
127
|
+
display: none;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
</style>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</head>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<body>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<div class="drop-upload">ファイルをドロップまたはクリックして選択してください
|
144
|
+
|
145
|
+
<input class="form-control" type="file">
|
146
|
+
|
147
|
+
<div class="preview"><img src="http://placehold.jp/150x150.png" alt></div>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
154
|
+
|
155
|
+
<script>
|
156
|
+
|
157
|
+
$('.drop-upload').on('click', () => {
|
158
|
+
|
159
|
+
$(".drop-upload").find('input[type="file"]').click();
|
160
|
+
|
161
|
+
});
|
162
|
+
|
163
|
+
$('.drop-upload > input[type="file"]').on("click", function(e) {
|
164
|
+
|
165
|
+
e.stopPropagation();
|
166
|
+
|
167
|
+
});
|
168
|
+
|
169
|
+
</script>
|
170
|
+
|
171
|
+
</body>
|
172
|
+
|
173
|
+
</body>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
</html>
|
178
|
+
|
179
|
+
```
|
1
修正
test
CHANGED
@@ -4,57 +4,73 @@
|
|
4
4
|
|
5
5
|
```HTML
|
6
6
|
|
7
|
+
<!DOCTYPE html>
|
8
|
+
|
7
9
|
<html lang="ja">
|
8
|
-
|
9
|
-
<style>
|
10
|
-
|
11
|
-
.drop-upload {
|
12
|
-
|
13
|
-
display: block;
|
14
|
-
|
15
|
-
border: 2px dotted #0B85A1;
|
16
|
-
|
17
|
-
color: #92AAB0;
|
18
|
-
|
19
|
-
text-align: left;
|
20
|
-
|
21
|
-
vertical-align: middle;
|
22
|
-
|
23
|
-
padding: 10px;
|
24
|
-
|
25
|
-
margin: 10px;
|
26
|
-
|
27
|
-
}
|
28
10
|
|
29
11
|
|
30
12
|
|
31
|
-
|
13
|
+
<head>
|
32
14
|
|
33
|
-
|
15
|
+
<meta charset="UTF-8">
|
34
16
|
|
17
|
+
<title>タイトル</title>
|
18
|
+
|
19
|
+
<style>
|
20
|
+
|
21
|
+
.drop-upload {
|
22
|
+
|
23
|
+
display: block;
|
24
|
+
|
25
|
+
border: 2px dotted #0B85A1;
|
26
|
+
|
27
|
+
color: #92AAB0;
|
28
|
+
|
29
|
+
text-align: left;
|
30
|
+
|
31
|
+
vertical-align: middle;
|
32
|
+
|
33
|
+
padding: 10px;
|
34
|
+
|
35
|
+
margin: 10px;
|
36
|
+
|
35
|
-
}
|
37
|
+
}
|
36
38
|
|
37
39
|
|
38
40
|
|
39
|
-
.p
|
41
|
+
.drop-upload input {
|
40
42
|
|
41
|
-
display:
|
43
|
+
display: none;
|
42
44
|
|
43
|
-
}
|
45
|
+
}
|
44
46
|
|
47
|
+
|
48
|
+
|
49
|
+
.preview {
|
50
|
+
|
51
|
+
display: block;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
45
|
-
</style>
|
55
|
+
</style>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
</head>
|
46
60
|
|
47
61
|
|
48
62
|
|
49
63
|
<body>
|
50
64
|
|
65
|
+
|
66
|
+
|
51
67
|
<label class="drop-upload">ファイルをドロップまたはクリックして選択してください
|
52
68
|
|
53
|
-
|
69
|
+
<input class="form-control" type="file">
|
54
70
|
|
55
|
-
|
71
|
+
<span class="preview"><img src="http://placehold.jp/150x150.png" alt></span>
|
56
72
|
|
57
|
-
|
73
|
+
</label>
|
58
74
|
|
59
75
|
|
60
76
|
|