回答編集履歴

1

ここまで以降対応、5つ目display:none;問題対応

2015/09/25 07:31

投稿

notable
notable

スコア415

test CHANGED
@@ -6,17 +6,13 @@
6
6
 
7
7
  $(function() {
8
8
 
9
- var count = 1;
9
+ var count = 0;
10
10
 
11
- $('#wrap_root').children('.kodomo').each(function() {
11
+ var anchorFlag = false;
12
12
 
13
- if(count >= 5){
13
+ var afterHtml = '';
14
14
 
15
- $(this).after($('<span>').html('ここまで'));
15
+ $('#wrap_root').children('.kodomo').each(function(){
16
-
17
- return false;
18
-
19
- }
20
16
 
21
17
  if($(this).css('display') != 'none'){
22
18
 
@@ -24,7 +20,33 @@
24
20
 
25
21
  }
26
22
 
23
+ if(count >= 5){
24
+
25
+ if(anchorFlag == false){
26
+
27
+ $(this).after($('<span>').html('ここまで'));
28
+
29
+ anchorFlag = true;
30
+
31
+ return true;
32
+
33
+ } else {
34
+
35
+ afterHtml += $(this).context.outerHTML;
36
+
37
+ $(this).remove();
38
+
39
+ }
40
+
41
+ }
42
+
27
43
  });
44
+
45
+ if(afterHtml != ''){
46
+
47
+ $('#wrap_root').append($('<div>').html(afterHtml));
48
+
49
+ }
28
50
 
29
51
  });
30
52