回答編集履歴
2
typo
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<style>
|
4
4
|
|
5
|
-
.hoge{height:100px;width
|
5
|
+
.hoge{height:100px;width:100px;padding:3px;}
|
6
6
|
|
7
7
|
.hoge.active{border:solid 3px red;padding:0px}
|
8
8
|
|
1
hover
test
CHANGED
@@ -35,3 +35,63 @@
|
|
35
35
|
<div class="hoge">ここに中身</div>
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# hover対応
|
42
|
+
|
43
|
+
```javascript
|
44
|
+
|
45
|
+
<style>
|
46
|
+
|
47
|
+
.hoge{height:100px;width:100px;padding:3px;}
|
48
|
+
|
49
|
+
.hoge.active{border:solid 3px red;padding:0px}
|
50
|
+
|
51
|
+
</style>
|
52
|
+
|
53
|
+
<script>
|
54
|
+
|
55
|
+
var timerId;
|
56
|
+
|
57
|
+
var idx=0;
|
58
|
+
|
59
|
+
$(function(){
|
60
|
+
|
61
|
+
$('.hoge').on('mouseover',function(){
|
62
|
+
|
63
|
+
clearInterval(timerId);
|
64
|
+
|
65
|
+
$('.hoge').removeClass('active');
|
66
|
+
|
67
|
+
$(this).addClass('active');
|
68
|
+
|
69
|
+
}).on('mouseout',function(){
|
70
|
+
|
71
|
+
timerId=setInterval(function(){
|
72
|
+
|
73
|
+
idx++;
|
74
|
+
|
75
|
+
idx%=$('.hoge').length;
|
76
|
+
|
77
|
+
$('.hoge').removeClass('active').eq(idx).addClass('active');
|
78
|
+
|
79
|
+
},1000);
|
80
|
+
|
81
|
+
idx=$('.hoge').index(this);
|
82
|
+
|
83
|
+
}).eq(0).trigger('mouseout');
|
84
|
+
|
85
|
+
});
|
86
|
+
|
87
|
+
</script>
|
88
|
+
|
89
|
+
<div class="hoge active">ここに中身</div>
|
90
|
+
|
91
|
+
<div class="hoge">ここに中身</div>
|
92
|
+
|
93
|
+
<div class="hoge">ここに中身</div>
|
94
|
+
|
95
|
+
<div class="hoge">ここに中身</div>
|
96
|
+
|
97
|
+
```
|