首页 > 代码库 > 判断文本框的取值

判断文本框的取值

 1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5     <title></title> 6     <script src="http://www.mamicode.com/jq/jquery-3.0.0.min.js"></script> 7 </head> 8 <body> 9     <input type="text" value="" id="a1" />10     <input type="text" value="" id="a2" />11     <input type="text" value="" id="a3" />12     <input type="text" value="" id="a4" />13     <input type="button" value="http://www.mamicode.com/确定" id="a5" />14     <script>15         $(document).ready(function () {16             $("input[type=‘button‘]").click(function () {17                 //alert("为空")18                 //数组19                 var num = $("input[type=‘text‘]");20                 var aaa = "";21                 for (var i = 0; i < num.length; i++) {22                     if (num.eq(i).val() == "") {23                         aaa += "第" + i + "个文本框为空";24                         //a+=b   相当于   a = a+b25                     }26                 }27                 alert(aaa);28             });29         });30     </script>31 </body>32 </html>

 

判断文本框的取值