在 if 语句中组合 Javascript 计数器或点击函数?
Combining Javascript counter OR click function in an if statement?
我正在创建一个按钮来记录点击次数。我想 show/hide 根据点击次数或点击上面导航选项卡的具体信息。我试图将计数器和点击功能与 (||) 结合使用,但我认为我设置不正确。我怎样才能实现这些事件中的任何一个的显示(计数器 || 点击选项卡)?
$(document).ready(function() {
$i = 0;
$(".proceedBtn").click(function(){
$i = $i + 1;
});
if ($i == 0) || $(".billing").click(function(){
$('#billingQuestions').show();
$('#billingQuestions2').show();
$('#noQuestions').hide();
$('#noQuestions2').hide();
$('#paymentInfo').hide();
$('#paymentInfo2').hide();
$('.arrow').css('left', '15%');
});
});
根据我的理解,你想根据计数器隐藏和显示提到的控件 value.ie 如果 counter=1,将决定这些控件是否可见,如果我的理解是正确的,请尝试使用下面的代码
$(document).ready(function() {
$i = 0;
});
$(document). on("click",".proceedBtn", function(){
$i = $i + 1;
});
$(document).
on("click",".billing",function(){
if ($i == 0){
$('#billingQuestions').show();
$('#billingQuestions2').show();
$('#noQuestions').hide();
$('#noQuestions2').hide();
$('#paymentInfo').hide();
$('#paymentInfo2').hide();
$('.arrow').css('left', '15%');
}
});
我正在创建一个按钮来记录点击次数。我想 show/hide 根据点击次数或点击上面导航选项卡的具体信息。我试图将计数器和点击功能与 (||) 结合使用,但我认为我设置不正确。我怎样才能实现这些事件中的任何一个的显示(计数器 || 点击选项卡)?
$(document).ready(function() {
$i = 0;
$(".proceedBtn").click(function(){
$i = $i + 1;
});
if ($i == 0) || $(".billing").click(function(){
$('#billingQuestions').show();
$('#billingQuestions2').show();
$('#noQuestions').hide();
$('#noQuestions2').hide();
$('#paymentInfo').hide();
$('#paymentInfo2').hide();
$('.arrow').css('left', '15%');
});
});
根据我的理解,你想根据计数器隐藏和显示提到的控件 value.ie 如果 counter=1,将决定这些控件是否可见,如果我的理解是正确的,请尝试使用下面的代码
$(document).ready(function() {
$i = 0;
});
$(document). on("click",".proceedBtn", function(){
$i = $i + 1;
});
$(document).
on("click",".billing",function(){
if ($i == 0){
$('#billingQuestions').show();
$('#billingQuestions2').show();
$('#noQuestions').hide();
$('#noQuestions2').hide();
$('#paymentInfo').hide();
$('#paymentInfo2').hide();
$('.arrow').css('left', '15%');
}
});