質問編集履歴

2

コードの追加

2018/06/04 04:07

投稿

sanezane
sanezane

スコア91

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,55 @@
26
26
 
27
27
 
28
28
 
29
+ ```html
30
+
31
+ <g id="PA18" class="hoge"
32
+
33
+ transform="translate(-0.12368393,25.421501)">
34
+
35
+ <rect style="display:inline;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.07969642;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
36
+
37
+ id="RECT6-1"
38
+
39
+ width="7.55512"
40
+
41
+ height="18.46151"
42
+
43
+ x="46.504688"
44
+
45
+ y="65.076912" />
46
+
47
+ <text xml:space="preserve"
48
+
49
+ style="font-style:normal;font-weight:normal;font-size:4.57837629px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26413709"
50
+
51
+ x="48.90873"
52
+
53
+ y="75.833351"
54
+
55
+ id="text1334-5"
56
+
57
+ transform="scale(1.0001351,0.99986491)"><tspan id="tspan1332-0"
58
+
59
+ x="48.90873"
60
+
61
+ y="75.833351"
62
+
63
+ style="stroke-width:0.26413709">6</tspan></text>
64
+
65
+ </g>
66
+
67
+ ```
68
+
29
69
  コンソールにてvar classname = document.getElementsByClassName("hoge");でconsole.log()をするとちゃんとクラス名が出ます。
70
+
71
+ ```javascript
72
+
73
+ var classname = document.getElementsByClassName("hoge");
74
+
75
+ console.log(classname);
76
+
77
+ ```
30
78
 
31
79
  構文が間違っているのでしょうか。
32
80
 

1

コード修正

2018/06/04 04:07

投稿

sanezane
sanezane

スコア91

test CHANGED
File without changes
test CHANGED
@@ -8,13 +8,15 @@
8
8
 
9
9
  ```javascript
10
10
 
11
- $(function () {
11
+ $(window).on('load', function () {
12
12
 
13
- var classname = document.getElementsByClassName("hoge");
13
+ var classname = document.getElementsByClassName('hoge').contentDocument;
14
+
15
+
14
16
 
15
17
  $(classname).on('click', function () {
16
18
 
17
- alert("click");
19
+ alert('反応した');
18
20
 
19
21
  });
20
22