Jquery 顺序DIV fadeIn/Out onClick-类更改
这个想法是有一个单一的锚或按钮,根据类有一个函数循环。我已经玩了一些东西,但总是被困在调用相同的函数,即使类已经更改 由于不能流利地使用jQuery,我甚至不确定这是否可能是我看到它的方式 我想要的效果是,这个按钮可以被垃圾邮件,这将在一个周期中继续添加div,但最终会在最后淡出 我试过几个例子:- HTML:Jquery 顺序DIV fadeIn/Out onClick-类更改,jquery,onclick,fadein,fadeout,sequential,Jquery,Onclick,Fadein,Fadeout,Sequential,这个想法是有一个单一的锚或按钮,根据类有一个函数循环。我已经玩了一些东西,但总是被困在调用相同的函数,即使类已经更改 由于不能流利地使用jQuery,我甚至不确定这是否可能是我看到它的方式 我想要的效果是,这个按钮可以被垃圾邮件,这将在一个周期中继续添加div,但最终会在最后淡出 我试过几个例子:- HTML: <a class="points first">Points</a> <div class="ten-points"> 10 Points &
<a class="points first">Points</a>
<div class="ten-points">
10 Points
</div>
<div class="twenty-points">
20 Points
</div>
<div class="no-points">
Lost your points
</div>
我相信我已经按照您想要的方式工作了:)问题是您没有在更改后动态检查当前类。更新的JSFIDLE
})) 我相信我已经按照您想要的方式运行了:)问题是您没有在更改后动态检查当前类。更新的JSFIDLE
})) 我相信我已经按照您想要的方式运行了:)问题是您没有在更改后动态检查当前类。更新的JSFIDLE
})) 我相信我已经按照您想要的方式运行了:)问题是您没有在更改后动态检查当前类。更新的JSFIDLE
})) 你可以这样做:
$(function () {
$('.points').click(function(){
if($(this).hasClass('first')){
$(this).removeClass('first');
$(this).addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('second')){
$(this).removeClass('second');
$(this).addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('third')){
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
});
});
你可以这样做:
$(function () {
$('.points').click(function(){
if($(this).hasClass('first')){
$(this).removeClass('first');
$(this).addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('second')){
$(this).removeClass('second');
$(this).addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('third')){
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
});
});
你可以这样做:
$(function () {
$('.points').click(function(){
if($(this).hasClass('first')){
$(this).removeClass('first');
$(this).addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('second')){
$(this).removeClass('second');
$(this).addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('third')){
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
});
});
你可以这样做:
$(function () {
$('.points').click(function(){
if($(this).hasClass('first')){
$(this).removeClass('first');
$(this).addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('second')){
$(this).removeClass('second');
$(this).addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
else if($(this).hasClass('third')){
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
}
});
});
取消绑定第一个事件并将新事件绑定到锚
$(function () {
$('.first').click(function () {
$('.points').removeClass('first').addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.second').click(function () {
$('.points').removeClass('second').addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.third').click(function () {
$('.points').removeClass('third').addClass('first');
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
});
});
});
});
取消绑定第一个事件并将新事件绑定到锚
$(function () {
$('.first').click(function () {
$('.points').removeClass('first').addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.second').click(function () {
$('.points').removeClass('second').addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.third').click(function () {
$('.points').removeClass('third').addClass('first');
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
});
});
});
});
取消绑定第一个事件并将新事件绑定到锚
$(function () {
$('.first').click(function () {
$('.points').removeClass('first').addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.second').click(function () {
$('.points').removeClass('second').addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.third').click(function () {
$('.points').removeClass('third').addClass('first');
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
});
});
});
});
取消绑定第一个事件并将新事件绑定到锚
$(function () {
$('.first').click(function () {
$('.points').removeClass('first').addClass('second');
$('.ten-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.second').click(function () {
$('.points').removeClass('second').addClass('third');
$('.twenty-points').fadeIn('slow').delay(2000).fadeOut('slow');
$('.points').unbind("click");
$('.third').click(function () {
$('.points').removeClass('third').addClass('first');
$('.no-points').fadeIn('slow').delay(2000).fadeOut('slow');
});
});
});
});
如果要执行循环或串行过程,请使用
Timeout
或setInterval
。@ArpitSrivastava,谢谢您的指导。我得读一下。干杯。如果您想执行循环或串行过程,请使用Timeout
或setInterval
。@ArpitSrivastava,谢谢您的指导。我得读一下。干杯。如果您想执行循环或串行过程,请使用Timeout
或setInterval
。@ArpitSrivastava,谢谢您的指导。我得读一下。干杯。如果您想执行循环或串行过程,请使用Timeout
或setInterval
。@ArpitSrivastava,谢谢您的指导。我得读一下。干杯