1 回答
![?](http://img1.sycdn.imooc.com/5333a1920001d36402200220-100-100.jpg)
绝地无双
TA贡献1946条经验 获得超4个赞
$("input[name='mobile'],input[name='codep']").on('input propertychange',function(){ var $this = $(this), val = $this.val(), $btn = $this.closest(".innercontent").find("button"); //这里的button标签最好有个类名来限制一下,比如button.btn-step,不然如果有多个button标签就会有问题。 if(val!=""){ $btn.prop('disabled',false).css('background','#6f60cf'); }else{ $btn.prop('disabled',true).css('background','#a396f7'); } });
attr和prop的用法是不同的,你可以看看jquery的官方文档有解释英文版,这是中文版。
关于你在答案一种的评论,你的这个.btn-stepa和.btn-stepb是可以优化的,前提是你让我看一下你的html结构。
添加回答
举报
0/150
提交
取消