Javascript “多步骤表格”;“下一步”;按钮不工作
我对Javascript和jQuery有基本的了解。我这里有一个多步骤表单,它将我的表单分为3个步骤。但是“下一步”按钮似乎不起作用。我花了一整天的时间在互联网上进行研究,尽我所能,但仍然没有解决我的问题 下面是我的档案。我确信这不是因为浏览器问题,因为我已经尝试了所有主要的浏览器。js代码在我看来也不错。谁能给我一些启示 new_video.html(它是一个.php文件,但我删除了所有不必要的php代码)Javascript “多步骤表格”;“下一步”;按钮不工作,javascript,jquery,html,forms,multi-step,Javascript,Jquery,Html,Forms,Multi Step,我对Javascript和jQuery有基本的了解。我这里有一个多步骤表单,它将我的表单分为3个步骤。但是“下一步”按钮似乎不起作用。我花了一整天的时间在互联网上进行研究,尽我所能,但仍然没有解决我的问题 下面是我的档案。我确信这不是因为浏览器问题,因为我已经尝试了所有主要的浏览器。js代码在我看来也不错。谁能给我一些启示 new_video.html(它是一个.php文件,但我删除了所有不必要的php代码) 目前我看到您只指定了一个步骤,对于初学者来说,将所有绑定放在一个$(document)
目前我看到您只指定了一个步骤,对于初学者来说,将所有绑定放在一个
$(document).ready
或简称$(function(){})代码>,因此:
$(function() {
$(".previous").click(function(){
// stuff for previous ...
});
$(".next").click(function(){
// stuff for next ...
});
$(".submit").click(function(){
// you get the idea ...
});
});
这是您的最新信息(您丢失了一些资源,我希望我没有弄错)。我希望这会有所帮助,祝你好运:)我可以简单地告诉你,你不需要那么多$(document).ready()
。你准备一把小提琴怎么样?@DimitarDimitrov很抱歉,我刚在网上学会小提琴就用了,现在还是js的新手。这是小提琴:如果你能给我一些建议,我将不胜感激。非常感谢!你帮我弄明白我的代码出了什么问题。除了你指出的美元(文件)。准备好了,我意识到了。在jquery版本中丢失一个数字的效果可能是灾难性的:(在线资源说前者会起作用,但我不知道为什么它在我的情况下不起作用。@user3148857真棒,我很高兴我能帮上忙:)哦,顺便说一句,设计非常棒:)坚持下去
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
$(document).ready(function(){
$(".next").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
next_fs.css({'left': left, 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
});
$(document).ready(function(){
$(".previous").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
previous_fs = $(this).parent().prev();
//de-activate current step on progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
//show the previous fieldset
previous_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale previous_fs from 80% to 100%
scale = 0.8 + (1 - now) * 0.2;
//2. take current_fs to the right(50%) - from 0%
left = ((1-now) * 50)+"%";
//3. increase opacity of previous_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'left': left});
previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
});
$(document).ready(function(){
$(".submit").click(function(){
return false;
});
});
$(function() {
$(".previous").click(function(){
// stuff for previous ...
});
$(".next").click(function(){
// stuff for next ...
});
$(".submit").click(function(){
// you get the idea ...
});
});