Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery-计算点击次数并相应执行_Javascript_Jquery_Count_Jquery Animate - Fatal编程技术网

Javascript jQuery-计算点击次数并相应执行

Javascript jQuery-计算点击次数并相应执行,javascript,jquery,count,jquery-animate,Javascript,Jquery,Count,Jquery Animate,$(文档).ready(函数(){ $(“.next”)。单击(函数(){ var计数=0; 如果(计数=0){ $(“.step1”).hide(“drop”,{direction:“left”},400); $(“.step2”).delay(800).show(“drop”,{direction:“right”},800); 计数+=1; console.log(“第一个下一个”); 返回; }; 如果(计数=1){ $(“.step2”).hide(“drop”,{direction:“

$(文档).ready(函数(){
$(“.next”)。单击(函数(){
var计数=0;
如果(计数=0){
$(“.step1”).hide(“drop”,{direction:“left”},400);
$(“.step2”).delay(800).show(“drop”,{direction:“right”},800);
计数+=1;
console.log(“第一个下一个”);
返回;
};
如果(计数=1){
$(“.step2”).hide(“drop”,{direction:“left”},800);
$(“.step3”).delay(800).show(“drop”,{direction:“right”},800);
计数+=1;
console.log(“第二个下一个”);
返回;
};
如果(计数=2){
$(“.step3”).hide(“drop”,{direction:“left”},800);
$(“.step4”).delay(800).show(“drop”,{direction:“right”},800);
计数+=1;
console.log(“第三次下一次”);
返回;
};
});
});
.processHeader{
字体系列:“Raleway”,无衬线;
文本对齐:居中;
位置:固定;
最高:0%;
垫面:3%;
字体大小:粗体;
左:50%;
宽度:100%;
身高:100%;
字体大小:粗体;
转化:translateX(-50%);
字体大小:220%;
显示:无;
颜色:白色;
z指数:4;
不透明度:.4;
}
.processContent{
字体系列:“Raleway”,无衬线;
文本对齐:居中;
位置:固定;
最高:20%;
左:50%;
垫面:5%;
宽度:80%;
身高:100%;
字体大小:粗体;
转化:translateX(-50%);
字体大小:220%;
显示:无;
背景色:白色;
颜色:rgb(115、115、115);
z指数:5;
对齐项目:居中;
不透明度:.4;
}
.下一个{
边界半径:4px;
背景色:黑色;
边界:无;
颜色:#FFFFFF;
文本对齐:居中;
字号:28px;
填充:20px;
宽度:200px;
过渡:均为0.5s;
光标:指针;
保证金:5px;
位置:绝对位置;
最高:50%;
转化:translateX(-50%);
}
.下一个跨度{
光标:指针;
显示:内联块;
位置:相对位置;
过渡:0.5s;
}
.下一个跨度:之后{
内容:'\00bb';
位置:绝对位置;
不透明度:0;
排名:0;
右:-20px;
过渡:0.5s;
}
.下一步:悬停跨度{
右边填充:25px;
}
.下一步:悬停范围:之后{
不透明度:1;
右:0;
}
.下一步:聚焦{
大纲:无;
}
.步骤{
左:5%;
右:5%;
字号:80%;
}
步骤二
步骤三
.步骤4{
显示:无;
}

我们的过程
我们的第一步就是胡说八道


我们的第二步是废话废话

我们的第三步是废话废话

我们的第四步是胡说八道


下一步
您的问题是每次单击“下一步”按钮时,都会将计数重置为0。每次单击按钮时,click listener都会作为一个全新的函数调用,因此需要在其外部初始化count变量

    $(document).ready(function(){
      var count = 0;  <<-- should be initialized outside of click listener
      $(".next").click(function(){         
        if (count == 0){
        $(".step1").hide("drop", {direction: "left"}, 400);
        $(".step2").delay(800).show("drop", {direction: "right"}, 800);
        count += 1;
        console.log("first next");
        return;
        };
        if (count == 1){
        $(".step2").hide("drop", {direction: "left"}, 800);
        $(".step3").delay(800).show("drop", {direction: "right"}, 800); 
        count += 1;
        console.log("second next");
        return;
        };
        if (count == 2){
        $(".step3").hide("drop", {direction: "left"}, 800);
        $(".step4").delay(800).show("drop", {direction: "right"}, 800);
        count += 1;
        console.log("third next");
        return;
        };
      });

    });
$(文档).ready(函数(){

var count=0;您的问题是,每次单击“下一步”按钮时,它都会将计数重置为0。每次单击按钮时,click listener都会作为一个全新的函数调用,因此您需要在其外部初始化计数变量

    $(document).ready(function(){
      var count = 0;  <<-- should be initialized outside of click listener
      $(".next").click(function(){         
        if (count == 0){
        $(".step1").hide("drop", {direction: "left"}, 400);
        $(".step2").delay(800).show("drop", {direction: "right"}, 800);
        count += 1;
        console.log("first next");
        return;
        };
        if (count == 1){
        $(".step2").hide("drop", {direction: "left"}, 800);
        $(".step3").delay(800).show("drop", {direction: "right"}, 800); 
        count += 1;
        console.log("second next");
        return;
        };
        if (count == 2){
        $(".step3").hide("drop", {direction: "left"}, 800);
        $(".step4").delay(800).show("drop", {direction: "right"}, 800);
        count += 1;
        console.log("third next");
        return;
        };
      });

    });
$(文档).ready(函数(){

var count=0;
count+=1;
不会对页面进行任何更新。您必须将该值注入元素。这可以通过
theElementReference.textContent=count完成;
count+=1;
不会对页面进行任何更新。您必须将该值注入元素。这可以通过
theElementRe完成ference.textContent=count;
别紧张!别紧张!