jQuery 在类中淡入淡出切换图像
我的一些代码中出现了一些问题。我的页面上有多个 HTML5 音频播放器,每个播放器都通过单击进入其容器时淡入的图像来播放。为了适应所有玩家使用相同的游戏图像,我将其设置为一个类。
我的问题是,当您淡入任何 .thumbnail 容器时,图像就会淡入。我需要以某种方式将其磨练到您输入的任何容器中..也许使用(这个)或其他东西。
HTML:
<div class="thumbnail" id="paparazzi">
<a class="playback">
<img class="play" src="http://www.lucisz.com/imgs/play.png" />
</a>
<audio>
<source src="../audio/fernando_garibay_paparazzisnlmix.ogg" type="audio/ogg" />
<source src="../audio/fernando_garibay_paparazzisnlmix.mp3" type="audio/mpeg" />
Your browser does not support HTML5 audio.
</audio>
</div>
JavaScript:
$('.play').hide();
$('.thumbnail').hover(function(){
$('.play').fadeToggle(400);
});
概念 JavaScript:
$('.play').hide();
$('this, .thumbnail').hover(function(){
$('.play').fadeToggle(400);
});
A few hitches in a bit of my code. I've got several HTML5 audio players on a page, each of which is played by clicking on an image that fades in when you enter its container. To accomodate the use of the same play image on all the players, I made it a class.
My issue is that when you fade into any of the .thumbnail containers the image fades in. I need to somehow hone it in to whichever container you entered.. maybe with (this) or something.
HTML:
<div class="thumbnail" id="paparazzi">
<a class="playback">
<img class="play" src="http://www.lucisz.com/imgs/play.png" />
</a>
<audio>
<source src="../audio/fernando_garibay_paparazzisnlmix.ogg" type="audio/ogg" />
<source src="../audio/fernando_garibay_paparazzisnlmix.mp3" type="audio/mpeg" />
Your browser does not support HTML5 audio.
</audio>
</div>
JavaScript:
$('.play').hide();
$('.thumbnail').hover(function(){
$('.play').fadeToggle(400);
});
Conceptual JavaScript:
$('.play').hide();
$('this, .thumbnail').hover(function(){
$('.play').fadeToggle(400);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是这样:
所以你几乎是对的。
举个例子:
http://jsfiddle.net.net/4nyqv/4/4nyqv/4/
编辑:对不起,对不起,对您有错误的方式。
Should be this:
So you were nearly right.
For an example:
http://jsfiddle.net/4NYqv/4/
Edit: Sorry, had it the wrong way around.