在jQuery中:jQuery的 - 点击并激活激活键
方案** - 我有悬停有对4周的div。 - 全部使用jQuery动画来移动backgroundPosition以显示悬停状态。
问题** - 我想成立一个焦点或点击的状态,所以,一旦你点击了一个按钮,它的动画背景的位置进一步以显示新的状态。我还想让按钮知道是否有任何其他按钮已被点击并移除当前点击状态并开始在新选定按钮上设置新的点击状态动画......?
我的努力** - 我已经提前再次做了一些编码,但不能似乎摸出这个焦点状态,谢谢! )
HTML **
<div class="rollOversHolderOne">
<div id="mainServices_01" class="rollOver_1 rollover"></div>
<div id="mainServices_02" class="rollOver_2 rollover"></div>
<div id="mainServices_03" class="rollOver_3 rollover"></div>
<div id="mainServices_04" class="rollOver_4 rollover"></div>
</div>
CSS **
#mainServices_01 {
width:103px;
height:131px;
float:left;
background:url(../images/slideHover.png) repeat 0 0;
background-position: inline;
}
#mainServices_02 {
width:103px;
height:131px;
float:left;
background:url(../images/slideHover.png) repeat 0 0;
background-position: inline;
}
#mainServices_03 {
width:103px;
height:131px;
float:left;
background:url(../images/slideHover.png) repeat 0 0;
background-position: inline;
}
#mainServices_04 {
width:103px;
height:131px;
float:left;
background:url(../images/slideHover.png) repeat 0 0;
background-position: inline;
}
jQuery的**
jQuery(document).ready(function(){
var flag;
var active;
jQuery('.rollover').css({backgroundPosition: "0 0"}).click(function(){
flag = false;
jQuery(this).stop().animate(
{backgroundPosition:"(0 -130.5px)"},
{duration:1});
});
jQuery('.rollover').mouseout(function(){
if(flag == false)
{
jQuery(this).stop().animate(
{backgroundPosition:"(0 -130.5px)"},
{duration:1})
}else{
jQuery(this).stop().animate(
{backgroundPosition:"(0 0)"},
{duration:1})
}
});
jQuery('.rollover').mouseover(function(){
jQuery(this).stop().animate(
{backgroundPosition:"(0 -130.5px)"},
{duration:1})
flag = true;
});
});
@Pablo费尔南德斯 - 无后顾之忧,他们中的一些正确的werent虽然..? –