我刚开始学习jquery,我很幸运能够找到工作。 我的第一个代码是在按下按钮时创建“Dim the light”效果,当灯光熄灭时创建“显示灯光”。这部分工作很好。jQuery在mouseout上隐藏元素()
下面的代码:
$(document).ready(function(){
$(".dimlight").click(function(){
$("#overlay").fadeIn();
$(".dimlight").hide();
$(".showlight").show();
});
$(".showlight").click(function(){
$("#overlay").fadeOut();
$(".dimlight").show();
$(".showlight").hide();
});
});
现在我想采取了一步。我想在mouseout上隐藏任何可见按钮(.showlight或.dimlight)。基本上,活动按钮应该只在用户悬停播放器时才可见(#播放器div)。现在我试着去做,但没有奏效。我怀疑语法错了。它确实看起来很幼稚,对不起,伙计们。这是我的第一次尝试,我希望通过这样做来学习。
下面是扩展的代码do not't工作。
$(document).ready(function(){
$(".dimlight").click(function(){
$("#overlay").fadeIn();
$(".dimlight").hide();
$(".showlight").show();
});
$(".showlight").click(function(){
$("#overlay").fadeOut();
$(".dimlight").show();
$(".showlight").hide();
});
$("#player").mouseover(function(){
if ($('#overlay').is(':hidden')) {
$('.dimlight').show();
} else {
$('.showlight').show();
}
}).mouseout(function() {
if ($('.dimlight').is(':hidden')) {
$('.showlight').hide();
} else {
$('.dimlight').hide();
}
});
});
任何帮助,非常感谢。
He're的HTML:
<div id="videoplayer_two-col">
<span class="dimlight" title="Baisser la lumière">Baisser la lumière</span>
<span class="showlight" title="Alumer la lumière">Alumer la lumière</span>
<video id="player" width="633" height="320" poster="assets/components/ME/media/echo-hereweare.jpg" volume="0.5" controls preload="none">
<!-- MP4 source must come first for iOS -->
<source type="video/mp4" src="assets/components/ME/media/echo-hereweare.mp4" />
<object width="633" height="320" type="application/x-shockwave-flash" data="assets/components/ME/build/flashmediaelement.swf">
<param name="movie" value="assets/components/ME/build/flashmediaelement.swf" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="controls=true&file=assets/components/ME/media/media/echo-hereweare.mp4" />
<!-- Image fall back for non-HTML5 browser with JavaScript turned off and no Flash player installed -->
<img src="assets/components/ME/media/echo-hereweare.jpg" width="640" height="360" alt="Here we are"
title="No video playback capabilities" />
</object>
</video>
哪里'#overlay'元素? – papaiatis 2012-02-10 07:46:54
如果您只有一个'.dimlight'和'.showlight'元素,请考虑使用ID而不是类! – papaiatis 2012-02-10 07:50:00