$("input[name='mobile']").on('input propertychange',function(){
var mobile = $(this).val();
if(mobile!=""){
$(".btn-stepa").removeAttr("disabled").css('background','#6f60cf');
}
else{
$(".btn-stepa").attr('disabled',"disabled").css('background','#a396f7');
}
});
$("input[name='codep']").on('input propertychange',function(){
var codep = $(this).val();
if(codep!=""){
$(".btn-stepb").removeAttr("disabled").css('background','#6f60cf');
}
else{
$(".btn-stepb").attr('disabled',"disabled").css('background','#a396f7');
}
});
本人新手,请不要给负分哦~
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
attr和prop的用法是不同的,你可以看看jquery的官方文档有解释英文版,这是中文版。
关于你在答案一种的评论,你的这个.btn-stepa和.btn-stepb是可以优化的,前提是你让我看一下你的html结构。
多看文档。
最好把事件委托给document 这样在input后续插入时依然有效
大概可以修改成这样吧!试试看
这样试试