teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

修正

2021/11/30 07:51

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -1,14 +1,14 @@
1
1
  下記でどうでしょう。
2
+ ※印の3行追加しました。
2
3
 
3
-
4
4
  ```js
5
5
  $(document).ready(function () {
6
6
  $("td, .tbth").hover(function () {
7
7
  $(this).not('th').addClass('hover');
8
8
  $(this).siblings().not('th').addClass('hover');
9
9
  var index = $(this).index();
10
- if($(this).prop("tagName") === "TH"){++index} //
10
+ if($(this).prop("tagName") === "TH"){++index} //
11
- if(index === 0){return}
11
+ if(index === 0){return} // ※
12
12
  $(this).closest('table').find('tr').each(function () {
13
13
  if ($('td, th', this).length > 0) {
14
14
  $('td', this).eq(index).not('.standard_table_td').addClass('hover');
@@ -20,7 +20,7 @@
20
20
  $(this).removeClass('hover');
21
21
  $(this).siblings().not('th').removeClass('hover');
22
22
  var index = $(this).index();
23
- if($(this).prop("tagName") === "TH"){++index};
23
+ if($(this).prop("tagName") === "TH"){++index} // ※
24
24
  $(this).closest('table').find('tr').each(function () {
25
25
  if ($('td, th', this).length > 0) {
26
26
  $('td', this).eq(index).not('.standard_table_td').removeClass('hover');