質問編集履歴

1

詳細なコードの記載

2015/06/16 07:25

投稿

141kanae
141kanae

スコア28

test CHANGED
File without changes
test CHANGED
@@ -39,3 +39,115 @@
39
39
  ブラウザ依存の問題なのでしょうか。
40
40
 
41
41
  考えられる原因があれば、小さなことでも構いませんのでご協力頂ければ助かります。
42
+
43
+
44
+
45
+ ###HTML
46
+
47
+ <ul id="home" class="gnavi">
48
+
49
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="115" height="46" id="home" /></a></li>
50
+
51
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="157" height="46" class="btn" /></a></li>
52
+
53
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="157" height="46" class="btn" /></a></li>
54
+
55
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="157" height="46" class="btn" /></a></li>
56
+
57
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="157" height="46" class="btn" /></a></li>
58
+
59
+ <li><a href="/"><img src="○○○.gif" alt="○○○" width="157" height="46" class="btn" /></a></li>
60
+
61
+
62
+
63
+ ###JS(http://www.kyosuke.jp/yugajs/)
64
+
65
+ <script type="text/javascript" src="/design/btoner/js/yuga.js" charset="utf-8"></script>
66
+
67
+
68
+
69
+ //ロールオーバー
70
+
71
+ rollover: function(options) {
72
+
73
+ var c = $.extend({
74
+
75
+ hoverSelector: '.btn, .allbtn img',
76
+
77
+ groupSelector: '.btngroup',
78
+
79
+ postfix: '_on'
80
+
81
+ }, options);
82
+
83
+ //ロールオーバーするノードの初期化
84
+
85
+ var rolloverImgs = $(c.hoverSelector).filter(isNotCurrent);
86
+
87
+ rolloverImgs.each(function(){
88
+
89
+ this.originalSrc = $(this).attr('src');
90
+
91
+ this.rolloverSrc = this.originalSrc.replace(new RegExp('('+c.postfix+')?(\.gif|\.jpg|\.png)$'), c.postfix+"$2");
92
+
93
+ this.rolloverImg = new Image;
94
+
95
+ this.rolloverImg.src = this.rolloverSrc;
96
+
97
+ });
98
+
99
+ //グループ内のimg要素を指定するセレクタ生成
100
+
101
+ var groupingImgs = $(c.groupSelector).find('img').filter(isRolloverImg);
102
+
103
+
104
+
105
+ //通常ロールオーバー
106
+
107
+ rolloverImgs.not(groupingImgs).hover(function(){
108
+
109
+ $(this).attr('src',this.rolloverSrc);
110
+
111
+ },function(){
112
+
113
+ $(this).attr('src',this.originalSrc);
114
+
115
+ });
116
+
117
+ //グループ化されたロールオーバー
118
+
119
+ $(c.groupSelector).hover(function(){
120
+
121
+ $(this).find('img').filter(isRolloverImg).each(function(){
122
+
123
+ $(this).attr('src',this.rolloverSrc);
124
+
125
+ });
126
+
127
+ },function(){
128
+
129
+ $(this).find('img').filter(isRolloverImg).each(function(){
130
+
131
+ $(this).attr('src',this.originalSrc);
132
+
133
+ });
134
+
135
+ });
136
+
137
+ //フィルタ用function
138
+
139
+ function isNotCurrent(i){
140
+
141
+ return Boolean(!this.currentSrc);
142
+
143
+ }
144
+
145
+ function isRolloverImg(i){
146
+
147
+ return Boolean(this.rolloverSrc);
148
+
149
+ }
150
+
151
+
152
+
153
+ },