回答編集履歴
4
サンプル修正
answer
CHANGED
@@ -27,18 +27,17 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
#サンプル2
|
30
|
-
```
|
30
|
+
```HTML
|
31
31
|
<p class="test"><a href="xxx" target="_blank">テキストテキスト</a></p>
|
32
32
|
<p class="test"><a href="xxx" target="_blank">テキスト2テキスト2</a></p>
|
33
33
|
<p class="test"><div>テキスト3テキスト3</div></p>
|
34
34
|
<p class="test"><span>テキスト4テキスト4</span><a href="xxx" target="_blank">テキスト5テキスト5</a></p>
|
35
|
-
|
35
|
+
```
|
36
|
-
|
36
|
+
```javascript
|
37
37
|
$(function(){
|
38
38
|
$("p.test").find("a").each(function() {
|
39
39
|
$(this).parent().after($(this).parent().html());
|
40
40
|
$(this).parent().remove();
|
41
41
|
});
|
42
42
|
});
|
43
|
-
</script>
|
44
43
|
```
|
3
サンプル2
answer
CHANGED
@@ -15,7 +15,6 @@
|
|
15
15
|
});
|
16
16
|
</script>
|
17
17
|
```
|
18
|
-
|
19
18
|
懸念点としては3点あります。
|
20
19
|
- DOM読み込み後に処理しているのでCSSでtestに何かしら指定しているとチラッと見えてから消える
|
21
20
|
- ブラウザ「ソース表示」からは消えているわけではない
|
@@ -23,4 +22,23 @@
|
|
23
22
|
|
24
23
|
------------------
|
25
24
|
ある特定のもののみとはいえpタグを消したい理由によって対応方法も異なってくるようにも思います。
|
26
|
-
場合によってはそのクラスに対してpタグの機能が無効となるようなcssの指定をした方がいいかもしれませんし。
|
25
|
+
場合によってはそのクラスに対してpタグの機能が無効となるようなcssの指定をした方がいいかもしれませんし。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
#サンプル2
|
30
|
+
```
|
31
|
+
<p class="test"><a href="xxx" target="_blank">テキストテキスト</a></p>
|
32
|
+
<p class="test"><a href="xxx" target="_blank">テキスト2テキスト2</a></p>
|
33
|
+
<p class="test"><div>テキスト3テキスト3</div></p>
|
34
|
+
<p class="test"><span>テキスト4テキスト4</span><a href="xxx" target="_blank">テキスト5テキスト5</a></p>
|
35
|
+
<script src="./jquery.js"></script>
|
36
|
+
<script>
|
37
|
+
$(function(){
|
38
|
+
$("p.test").find("a").each(function() {
|
39
|
+
$(this).parent().after($(this).parent().html());
|
40
|
+
$(this).parent().remove();
|
41
|
+
});
|
42
|
+
});
|
43
|
+
</script>
|
44
|
+
```
|
2
修正
answer
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
```javascript
|
9
9
|
//jQueryによる記述です
|
10
10
|
$(function(){
|
11
|
-
$(".test").each(function() {
|
11
|
+
$("p.test").each(function() {
|
12
12
|
$(this).after($(this).html());
|
13
13
|
$(this).remove();
|
14
14
|
});
|
1
修正
answer
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
<p class="test"><a href="xxx" target="_blank">テキスト3テキスト3</a></p>
|
7
7
|
```
|
8
8
|
```javascript
|
9
|
+
//jQueryによる記述です
|
9
10
|
$(function(){
|
10
11
|
$(".test").each(function() {
|
11
12
|
$(this).after($(this).html());
|
@@ -15,10 +16,11 @@
|
|
15
16
|
</script>
|
16
17
|
```
|
17
18
|
|
18
|
-
懸念点としては
|
19
|
+
懸念点としては3点あります。
|
19
20
|
- DOM読み込み後に処理しているのでCSSでtestに何かしら指定しているとチラッと見えてから消える
|
21
|
+
- ブラウザ「ソース表示」からは消えているわけではない
|
20
22
|
- <p>タグ自体が除かれるので改行的なところも無効となる(PHPで削除する場合も同じ)
|
21
23
|
|
22
24
|
------------------
|
23
|
-
ある特定とはいえpタグを消したい理由によって対応方法も異なって
|
25
|
+
ある特定のもののみとはいえpタグを消したい理由によって対応方法も異なってくるようにも思います。
|
24
26
|
場合によってはそのクラスに対してpタグの機能が無効となるようなcssの指定をした方がいいかもしれませんし。
|