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

回答編集履歴

1

調整

2021/03/23 05:32

投稿

yambejp
yambejp

スコア117817

answer CHANGED
@@ -1,21 +1,1 @@
1
- ```javascript
2
- function changeImgSrc(t){
3
- if($(t).is('img[src$=".jpg"]:not([src$="-active.jpg"])')){
4
- $.cookie('imgIndex',$('img').index(t));
5
- $('img[src$="-active.jpg"]').attr('src',function(){return $(this).attr('src').replace(/-active(?=.jpg$)/,'')});
6
- $(t).attr('src',$(t).attr('src').replace(/(?=.jpg$)/,'-active'));
7
- }
8
- }
9
- $(window).on('pageshow',function(){
10
- changeImgSrc($('img').eq($.cookie('imgIndex')));
11
- });
12
- $(function(){
13
- $('a').on('click',function(e){
14
- e.preventDefault();
1
+ ごめんなさい、回答する質問間違えました
15
- changeImgSrc(e.target);
16
- setTimeout(function(){
17
- location.href=$(this).closest('a').attr('href');
18
- }.bind(this),100);
19
- });
20
- });
21
- ```