回答編集履歴

1

そーす

2016/10/26 15:57

投稿

hiim
hiim

スコア1689

test CHANGED
@@ -1,3 +1,29 @@
1
1
  カスタム属性を使えば可能ではありますね。
2
2
 
3
3
  http://dresscording.com/blog/html5/custom_data_attribute.html
4
+
5
+
6
+
7
+ ```html
8
+
9
+ <input type="checkbox" name="mobile" data-name="android" value = "500">android
10
+
11
+ <input type="checkbox" name="mobile" data-name="iphone" value = "800">iphone
12
+
13
+ ```
14
+
15
+ ```javascript
16
+
17
+ var selected = [];
18
+
19
+ for (var i = 0; i < mobiles.length; i++) {
20
+
21
+     if (mobiles[i].checked) {
22
+
23
+     selected.push(parseInt(mobiles[i].value));
24
+
25
+     console.log(mobiles[i].getAttribute('data-name'));
26
+
27
+ }
28
+
29
+ ```