回答編集履歴

1

コードの内容を変更

2017/03/30 05:04

投稿

taqm
taqm

スコア65

test CHANGED
@@ -22,25 +22,11 @@
22
22
 
23
23
  $(function() {
24
24
 
25
- // あらかじめ何列目なのかの情報を付与しておく
26
-
27
- $('.matrix tr').each(function() {
28
-
29
- $('> *' this).each(function(e, idx) {
30
-
31
- $(this).data('idx', idx);
32
-
33
- });
34
-
35
- });
36
-
37
-
38
-
39
- // マウスイベントの追加
40
-
41
25
  $('.matrix').find('th, td').on('mouseenter', function() {
42
26
 
27
+ // マウスカーソルがのっているセルが左から何番目かを取得
28
+
43
- var idx = $(this).data('idx');
29
+ var idx = $(this).parent().find('th, td').index(this);
44
30
 
45
31
  if (idx <= 0) return;
46
32