回答編集履歴
4
勘違い修正
answer
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
こんな感じでよろしいですかね?
|
2
|
-
列の長さ分、それを
|
2
|
+
列の長さ分のspanを取得して、それを置くようにします。
|
3
3
|
|
4
4
|
```html
|
5
5
|
<script>
|
6
6
|
$(function(){
|
7
|
+
let len = $('.main').find('td').not(':first').length;
|
7
8
|
let attr = [
|
8
|
-
'<td class="attribute">1</td>',
|
9
|
-
'<td class="
|
9
|
+
'<td class="attribute" colspan="'+len+'">1</td>',
|
10
|
+
'<td class="attribute_sub" colspan="'+len+'">2</td>',
|
10
11
|
];
|
11
|
-
let len = $('.main').find('td').not(':first').length; //先頭列以外の長さ取得
|
12
|
-
for(i= 0; i < len ; i++){
|
13
|
-
|
12
|
+
$( '#attribute_function').after(attr[0]);
|
14
|
-
|
13
|
+
$( '#attribute_sub_function').after(attr[1]);
|
15
|
-
}
|
16
14
|
})
|
17
15
|
</script>
|
16
|
+
|
18
17
|
</head>
|
19
18
|
<body>
|
20
19
|
<table id="tbl1" border="1">
|
3
先頭列以外
answer
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
'<td class="attribute">1</td>',
|
9
9
|
'<td class="attribute_sub">2</td>',
|
10
10
|
];
|
11
|
-
let len = $('.main').find('td').not(':first').length;
|
11
|
+
let len = $('.main').find('td').not(':first').length; //先頭列以外の長さ取得
|
12
12
|
for(i= 0; i < len ; i++){
|
13
13
|
$( '#attribute_function').after(attr[0]);
|
14
14
|
$( '#attribute_sub_function').after(attr[1]);
|
2
lenですね
answer
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
'<td class="attribute_sub">2</td>',
|
10
10
|
];
|
11
11
|
let len = $('.main').find('td').not(':first').length;
|
12
|
-
for(i= 0; i <
|
12
|
+
for(i= 0; i < len ; i++){
|
13
13
|
$( '#attribute_function').after(attr[0]);
|
14
14
|
$( '#attribute_sub_function').after(attr[1]);
|
15
15
|
}
|
1
afterでいけそうです
answer
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
];
|
11
11
|
let len = $('.main').find('td').not(':first').length;
|
12
12
|
for(i= 0; i < attr.length ; i++){
|
13
|
-
$( '#attribute_function').
|
13
|
+
$( '#attribute_function').after(attr[0]);
|
14
|
-
$( '#attribute_sub_function').
|
14
|
+
$( '#attribute_sub_function').after(attr[1]);
|
15
15
|
}
|
16
16
|
})
|
17
17
|
</script>
|