[英]How to Trigger an event on button click using jQuery
我有一个约会插件,可以选择以复选框方式选择特定日期。 我为该字段添加了自定义验证。 一切正常。 当我们单击下一步并到达下一步时,将有一个后退按钮。 当我们单击“后退”按钮时,它将直接进入表格而无需刷新数据,因此几天内的“我的自定义验证”无效。
这是我的代码,
jQuery(document).ready(function(){
setTimeout(function(){
jQuery(".ladda-button").attr('onclick','oniter()');
},1750);
});
function oniter(){
if (jQuery(".valid").find(".active").length>=1) {
alert(123);
} else {
jQuery('.removeval').remove();
jQuery(".validation_text").append("<font class='removeval'>Please Select a Day</font>");
}
jQuery(".valid").on ('change',function(){
jQuery(".validation_text").remove();
});
}
这就是我的验证方式。 我想在单击“后退”按钮时触发整个过程,以确保进行验证。 这个想法怎么办?
jQuery(document).ready(function(){
jQuery(document).on('click','.ladda-button',function(){
oniter();
});
});
function oniter(){
if (jQuery(".valid").find(".active").length>=1) {
alert(123);
} else {
jQuery('.removeval').remove();
jQuery(".validation_text").append("<font class='removeval'>Please Select a Day</font>");
}
jQuery(".valid").on ('change',function(){
jQuery(".validation_text").remove();
});
}
表单的后退按钮应该具有某些类或ID,对吗? 因此,仅在单击后退按钮时触发相同的setTimeout即可。 FE
jQuery(document).on('click','.back-button',function(){
setTimeout(function(){
jQuery(".ladda-button").attr('onclick','oniter()');
},1750);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.