回答編集履歴
1
そーす
answer
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
カスタム属性を使えば可能ではありますね。
|
2
|
-
http://dresscording.com/blog/html5/custom_data_attribute.html
|
2
|
+
http://dresscording.com/blog/html5/custom_data_attribute.html
|
3
|
+
|
4
|
+
```html
|
5
|
+
<input type="checkbox" name="mobile" data-name="android" value = "500">android
|
6
|
+
<input type="checkbox" name="mobile" data-name="iphone" value = "800">iphone
|
7
|
+
```
|
8
|
+
```javascript
|
9
|
+
var selected = [];
|
10
|
+
for (var i = 0; i < mobiles.length; i++) {
|
11
|
+
if (mobiles[i].checked) {
|
12
|
+
selected.push(parseInt(mobiles[i].value));
|
13
|
+
console.log(mobiles[i].getAttribute('data-name'));
|
14
|
+
}
|
15
|
+
```
|