更新时间:2022-10-01 20:06:05
项目需要,自己写了一个jquery代码,该代码需要满足两个文本框都不为空值,按钮才可用激活状态。
请转载此文的朋友务必附带原文链接,谢谢。
原文链接:http://xuyran.blog.51cto.com/11641754/1827959
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<!DOCTYPE html> < html >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no" >
< script src = "../../js/jquery.js" ></ script >
< script src = "../../js/mui.min.js" ></ script >
< link href = "../../css/mui.min.css" rel = "stylesheet" />
< link rel = "stylesheet" href = "../../css/iconfont.css" >
< link rel = "stylesheet" href = "../../css/app.css" >
< title >红包设置</ title >
< script >
$(document).ready( function(){
$(".mui-input-row input").keyup(function(){
var value2 = $(this).parent().siblings().find("input").val();
if( this.value !=""&& value2 !=""){
$(".sc-btn button").attr("disabled",false);
}else{$(".sc-btn button").attr("disabled",true);}
});
}); </ script >
< style >
html,body{background: #fef9f4;}
.mui-content{padding-top: 20px;background: #fef9f4;}
.mui-input-row,.mui-input-row:last-child{width: 90%;margin: auto;background: #FFFFFF;margin-bottom: 10px;}
.mui-input-row label{font-family: "微软雅黑";}
h2{text-align: center;font-weight: normal;padding: 40px 0 0;}
.sc-btn{width: 90%;margin: auto;padding-top: 80px;}
.mui-btn-block{padding: 10px 0;}
.mui-btn-blue{background: #a02227;border: none;}
.mui-btn-blue.focus-active{background: #a02227;}
</ style >
</ head >
< body >
< div class = "mui-content" >
< div class = "mui-input-row" >
< label >红包个数</ label >
< input type = "text" placeholder = "填写红包个数" >
</ div >
< div class = "mui-input-row" >
< label >单个金额</ label >
< input type = "text" placeholder = "填写神灯币" >
</ div >
< h2 >¥30个神灯币</ h2 >
< div class = "sc-btn" >
< button type = "button" class = "mui-btn mui-btn-blue mui-btn-block" disabled = "disabled" >付款</ button >
</ div >
</ div >
</ body >
</ html >
|
效果预览: