質問するログイン新規登録

質問編集履歴

2

コードの追加

2018/06/04 04:07

投稿

sanezane
sanezane

スコア91

title CHANGED
File without changes
body CHANGED
@@ -12,6 +12,30 @@
12
12
  });
13
13
  ```
14
14
 
15
+ ```html
16
+ <g id="PA18" class="hoge"
17
+ transform="translate(-0.12368393,25.421501)">
18
+ <rect style="display:inline;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.07969642;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
19
+ id="RECT6-1"
20
+ width="7.55512"
21
+ height="18.46151"
22
+ x="46.504688"
23
+ y="65.076912" />
24
+ <text xml:space="preserve"
25
+ 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"
26
+ x="48.90873"
27
+ y="75.833351"
28
+ id="text1334-5"
29
+ transform="scale(1.0001351,0.99986491)"><tspan id="tspan1332-0"
30
+ x="48.90873"
31
+ y="75.833351"
32
+ style="stroke-width:0.26413709">6</tspan></text>
33
+ </g>
34
+ ```
15
35
  コンソールにてvar classname = document.getElementsByClassName("hoge");でconsole.log()をするとちゃんとクラス名が出ます。
36
+ ```javascript
37
+ var classname = document.getElementsByClassName("hoge");
38
+ console.log(classname);
39
+ ```
16
40
  構文が間違っているのでしょうか。
17
41
  ご教授お願いいたします。

1

コード修正

2018/06/04 04:07

投稿

sanezane
sanezane

スコア91

title CHANGED
File without changes
body CHANGED
@@ -3,10 +3,11 @@
3
3
 
4
4
  ### 現状コード
5
5
  ```javascript
6
- $(function () {
6
+ $(window).on('load', function () {
7
- var classname = document.getElementsByClassName("hoge");
7
+ var classname = document.getElementsByClassName('hoge').contentDocument;
8
+
8
9
  $(classname).on('click', function () {
9
- alert("click");
10
+ alert('反応した');
10
11
  });
11
12
  });
12
13
  ```