回答編集履歴

1

テキスト修正

2020/06/10 01:58

投稿

jun68ykt
jun68ykt

スコア9058

test CHANGED
@@ -29,3 +29,49 @@
29
29
 
30
30
 
31
31
  とすればよいのではと思います。参考になれば幸いです。
32
+
33
+
34
+
35
+ ### 追記
36
+
37
+
38
+
39
+ rowspanizerを調べてみましたが、確かに、ご質問の要件では使えそうにないですね。ご質問の要件では、
40
+
41
+
42
+
43
+ - `th` だけを結合する。
44
+
45
+ - 最初の行から、ある行までの `th` の内容は `男` であり、
46
+
47
+ - その行より後の行の `th` の内容は `女` である。
48
+
49
+
50
+
51
+ というものと解釈しました。このような要件を満たせばよいのであれば、以下でいかがでしょうか?
52
+
53
+
54
+
55
+
56
+
57
+ ```javascript
58
+
59
+ const headersCount = $('th').length;
60
+
61
+ const malesCount = $('th').filter(function() { return $(this).text() === '男'; }).length;
62
+
63
+
64
+
65
+ $('th').get(0).rowSpan = malesCount;
66
+
67
+ $('th').get(malesCount).rowSpan = headersCount - malesCount;
68
+
69
+ $('th:not([rowspan])').remove();
70
+
71
+ ```
72
+
73
+ - **動作確認用CodePen:** [https://codepen.io/jun68ykt/pen/ExPPgYW?editors=1010](https://codepen.io/jun68ykt/pen/ExPPgYW?editors=1010)
74
+
75
+
76
+
77
+ 参考になれば幸いです。