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

質問編集履歴

1

ご指摘頂いたコードブロックの修正、urlの修正

2016/11/29 06:30

投稿

silver_mouse2
silver_mouse2

スコア10

title CHANGED
File without changes
body CHANGED
@@ -4,22 +4,22 @@
4
4
 
5
5
  ※URLはすべてダミーです
6
6
 
7
- <script type="text/javascript">
7
+ ```javascript
8
8
 
9
9
  $.ajax({
10
- url: 'http://aaa.com/', //目的のアドレス
10
+ url: 'http://example.com/', //目的のアドレス
11
11
  cache: false,
12
12
  dataType:'html',
13
13
  success: function(html){
14
14
  var voice_cont1 = $(html).find('#voice');
15
15
  voice_cont1.find('img').each(function () {
16
- $(img).attr('src', 'http://bbb.com/wp/wp-content/themes/theme1/images/');
16
+ $(img).attr('src', 'http://example_1.com/wp/wp-content/themes/theme1/images/');
17
17
  });
18
18
  $('#voice_1').append(voice_cont1);
19
19
  }
20
20
  });
21
21
 
22
- </script>
22
+ ```
23
23
 
24
24
  要するに$.ajaxにて取得した目的のアドレスのhtmlの中にあるid="voice"のdiv要素を変数voice_cont1に代入して、さらにvoice_cont1内のimgのsrc属性を変更しようとしてるのですがうまくいかないのです。
25
25
 
@@ -27,20 +27,20 @@
27
27
 
28
28
  ちなみに下記のようなコードを書いてみましたがやはりだめでした。
29
29
 
30
- <script type="text/javascript">
31
30
 
31
+ ```javascript
32
32
  $.ajax({
33
- url: 'http://aaa.com/', //目的のアドレス
33
+ url: 'http://example.com/', //目的のアドレス
34
34
  cache: false,
35
35
  dataType:'html',
36
36
  success: function(html){
37
37
  var voice_cont1 = $(html).find('#voice');
38
- voice_cont1('img').attr('src').replace('images/' , 'http://bbb.com/wp/wp-content/themes/theme1/images/');
38
+ voice_cont1('img').attr('src').replace('images/' , 'http://example_1.com/wp/wp-content/themes/theme1/images/');
39
39
  $('#voice_1').append(voice_cont1);
40
40
  }
41
41
  });
42
+ ```
42
43
 
43
- </script>
44
44
 
45
45
  jqueryに対する基本的な知識が自分にはないように思うのですが、ご助言頂ければ幸いです。
46
46
  宜しくお願いします。