回答編集履歴
3
ちょうせい
answer
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
こんな感じの処理になります
|
2
2
|
(jQueryっぽく修正してあります)
|
3
3
|
```javascript
|
4
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
4
5
|
<script>
|
5
6
|
$(function(){
|
6
7
|
$($('.wrap').get(0).childNodes).filter(function(){
|
2
chousei
answer
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
こんな感じの処理になります
|
2
|
-
|
2
|
+
(jQueryっぽく修正してあります)
|
3
3
|
```javascript
|
4
4
|
<script>
|
5
5
|
$(function(){
|
6
|
-
var count=0;
|
7
|
-
$
|
6
|
+
$($('.wrap').get(0).childNodes).filter(function(){
|
8
|
-
|
7
|
+
return $(this).get(0).nodeName=="#text" && !$(this).get(0).nodeValue.match(/^\s+$/);
|
9
|
-
|
8
|
+
}).each(function(x){
|
10
|
-
|
9
|
+
$(this).wrap(`<span class="txt${x+1}">`);
|
11
|
-
}
|
12
10
|
});
|
13
11
|
});
|
14
12
|
</script>
|
1
chousei
answer
CHANGED
@@ -3,9 +3,11 @@
|
|
3
3
|
```javascript
|
4
4
|
<script>
|
5
5
|
$(function(){
|
6
|
+
var count=0;
|
6
|
-
|
7
|
+
$.each($('.wrap').get(0).childNodes,function(){
|
7
8
|
if($(this).get(0).nodeName=="#text" && !$(this).get(0).nodeValue.match(/^\s+$/)){
|
9
|
+
count++;
|
8
|
-
$(this).wrap(
|
10
|
+
$(this).wrap(`<span class="txt${count}">`);
|
9
11
|
}
|
10
12
|
});
|
11
13
|
});
|