Javascript 返回按钮到引导步骤
我正在我的网站上使用以下步骤插件/代码: 我想要的是,当我在第二个或第三个选项卡上时,我想显示一个返回到上一个div/step的按钮 如果添加带有Javascript 返回按钮到引导步骤,javascript,twitter-bootstrap,jquery-steps,Javascript,Twitter Bootstrap,Jquery Steps,我正在我的网站上使用以下步骤插件/代码: 我想要的是,当我在第二个或第三个选项卡上时,我想显示一个返回到上一个div/step的按钮 如果添加带有class=“backBtn”的按钮,如何使用javascript返回 $(document).ready(function () { var navListItems = $('div.setup-panel div a'), allWells = $('.setup-content'), allNex
class=“backBtn”
的按钮,如何使用javascript返回
$(document).ready(function () {
var navListItems = $('div.setup-panel div a'),
allWells = $('.setup-content'),
allNextBtn = $('.nextBtn');
allWells.hide();
navListItems.click(function (e) {
e.preventDefault();
var $target = $($(this).attr('href')),
$item = $(this);
if (!$item.hasClass('disabled')) {
navListItems.removeClass('btn-primary').addClass('btn-default');
$item.addClass('btn-primary');
allWells.hide();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allNextBtn.click(function(){
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
curInputs = curStep.find("input[type='text'],input[type='url']"),
isValid = true;
$(".form-group").removeClass("has-error");
for(var i=0; i<curInputs.length; i++){
if (!curInputs[i].validity.valid){
isValid = false;
$(curInputs[i]).closest(".form-group").addClass("has-error");
}
}
if (isValid)
nextStepWizard.removeAttr('disabled').trigger('click');
});
$('div.setup-panel div a.btn-primary').trigger('click');
});
$(文档).ready(函数(){
var navListItems=$('div.setup-panel div a'),
allWells=$('.setup content'),
allNextBtn=$('.nextBtn');
隐藏();
导航列表项。单击(函数(e){
e、 预防默认值();
var$target=$($(this.attr('href')),
$item=$(此项);
if(!$item.hasClass('disabled')){
navListItems.removeClass('btn-primary').addClass('btn-default');
$item.addClass('btn-primary');
隐藏();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allNextBtn.单击(函数(){
var curStep=$(this).closest(“.setup content”),
curStepBtn=curStep.attr(“id”),
nextStepWizard=$('div.setup-panel div a[href=“#”+curStepBtn+'“]”)parent().next().children(“a”),
curInputs=curStep.find(“输入[type='text'],输入[type='url']”),
isValid=true;
$(“.form group”).removeClass(“有错误”);
对于下面的(var i=0;i,您有一个工作示例。我使用了您提供的链接中的代码。我所做的如下:
- 添加了两个后退按钮=>
back
- 查看了
next
函数是如何实现的,并反转了该行为
当你按back键时,我也会禁用下一步,这是应该的。如果你也想清除这些值,可以很容易地完成,但这是你的家庭作业
干杯
$(文档).ready(函数(){
var navListItems=$('div.setup-panel div a'),
allWells=$('.setup content'),
allNextBtn=$('.nextBtn'),
allBackBtn=$('.backBtn');
隐藏();
导航列表项。单击(函数(e){
e、 预防默认值();
var$target=$($(this.attr('href')),
$item=$(此项);
if(!$item.hasClass('disabled')){
navListItems.removeClass('btn-primary').addClass('btn-default');
$item.addClass('btn-primary');
隐藏();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allNextBtn.单击(函数(){
var curStep=$(this).closest(“.setup content”),
curStepBtn=curStep.attr(“id”),
nextStepWizard=$('div.setup-panel div a[href=“#”+curStepBtn+'“]”)parent().next().children(“a”),
curInputs=curStep.find(“输入[type='text'],输入[type='url']”),
isValid=true;
$(“.form group”).removeClass(“有错误”);
对于(var i=0;i