我看过类似的问题但到目前为止还没有解决方案。我正在使用jQuery Steps表单,我试图在点击时禁用提交按钮,并且还会更改外观。我尝试过使用:
$('finish').attr('disabled',true);
但这没效果。当我单击按钮时,它不会禁用该按钮或更改外观。当我点击两次时,它会向我发送两封带有测试表格的电子邮件。
编辑:我不是要删除“输入”,我正在尝试删除“提交”按钮,jQuery文档列为“完成”。
我的完整JS就在下面。
$(function(){
$("#smart-form").steps({
bodyTag: "fieldset",
headerTag: "h2",
bodyTag: "fieldset",
transitionEffect: "fade",
titleTemplate: "<span class='number'>#index#</span> #title#",
labels: {
finish: "Submit Form",
next: "Continue",
previous: "Go Back",
loading: "Loading..."
},
onStepChanging: function (event, currentIndex, newIndex){
if (currentIndex > newIndex){return true; }
var form = $(this);
if (currentIndex < newIndex){}
return form.valid();
},
onStepChanged: function (event, currentIndex, priorIndex){
},
onFinishing: function (event, currentIndex){
var form = $(this);
$('finish').attr('disabled',true);
form.validate().settings.ignore = ":disabled";
return form.valid();
},
onFinished: function (event, currentIndex){
var form = $(this);
$(form).ajaxSubmit({
target:'.result',
beforeSubmit:function(){
//$('.form-footer').addClass('progress');
},
error:function(){
//$('.form-footer').removeClass('progress');
},
success:function(){
$('.alert-success').show().delay(10000).fadeOut();
//$("#wizard").steps('done');
//$("#smart-form").steps('reset');
//setCurrentIndex();
//startIndex: 0
//reset();
/*$('.form-footer').removeClass('progress');
$('.alert-success').show().delay(10000).fadeOut();
$('.field').removeClass("state-error, state-success");
if( $('.alert-error').length == 0){
$('#smart-form').resetForm();
reloadCaptcha();
}*/
}
})
}
答案 0 :(得分:1)
试试这个......
//Applying colour for finish button
var result = $('ul[aria-label=Pagination]').children().find('a');
$(result).each(function () {
if ($(this).text() == 'Finish') {
$(this).attr('disabled', true);
$(this).css('background', 'green');
}
});