回答編集履歴
2
修正
answer
CHANGED
@@ -36,4 +36,14 @@
|
|
36
36
|
</p>
|
37
37
|
</li>
|
38
38
|
</ul>
|
39
|
+
```
|
40
|
+
# 修正
|
41
|
+
完全に勘違い最初の<br>と2番目の文字列を削除するんですね
|
42
|
+
これでどうでしょう?
|
43
|
+
|
44
|
+
```javascript
|
45
|
+
$('.name').each(function(){
|
46
|
+
$(this).contents().eq(2).remove().end().filter('br').eq(0).remove();
|
47
|
+
});
|
48
|
+
|
39
49
|
```
|
1
調整
answer
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
最初の(テキスト)ノードだけ抜き出すという考え方もあります
|
2
2
|
|
3
|
+
- 案1
|
3
4
|
```javascript
|
4
5
|
$(function(){
|
6
|
+
$('.name').html(function(){return $(this).contents().first().text()});
|
7
|
+
});
|
8
|
+
```
|
9
|
+
- 案2
|
10
|
+
```javascript
|
11
|
+
$(function(){
|
5
12
|
$('.name').each(function(){
|
6
13
|
$(this).html($(this).get(0).firstChild);
|
7
14
|
});
|