回答編集履歴

1

参考

2023/06/05 04:17

投稿

yambejp
yambejp

スコア115201

test CHANGED
@@ -2,3 +2,33 @@
2
2
  ```javascript
3
3
  $('.news__area ul').fadeOut(300).eq(index).fadeIn(300);
4
4
  ```
5
+ 参考
6
+ ```javascript
7
+ <style>
8
+ .hoge.active{
9
+ color:red;
10
+ }
11
+ .fuga{
12
+ position:absolute;
13
+ }
14
+ </style>
15
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
16
+ <script>
17
+ $(function(){
18
+ $('.hoge:eq(0)').addClass('active');
19
+ $('.fuga:gt(0)').hide();
20
+ $('.hoge').on('click',function(){
21
+ var index=$('.hoge').index(this);
22
+ $('.hoge').removeClass('active');
23
+ $(this).addClass('active');
24
+ $('.fuga').fadeOut(300).eq(index).fadeIn(300);
25
+ });
26
+ });
27
+ </script>
28
+ <div class="hoge">hoge1</div>
29
+ <div class="hoge">hoge2</div>
30
+ <div class="hoge">hoge3</div>
31
+ <div class="fuga">fuga1</div>
32
+ <div class="fuga">fuga2</div>
33
+ <div class="fuga">fuga3</div>
34
+ ```