几个input必须都填写否则button灰化

html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>title>
    <link rel="stylesheet" href="bootstrap.min.css">
    <style type="text/css">
        body{
            padding: 30px;
        }
        a:hover,.btn1{
            font-size:1.2rem;
            border-radius:2px;
            height:2rem;
            line-height:2rem;
            color:#999;
            border-bottom:.3rem solid #bbb;
            text-align:center;
            display:block;
            background:#f5f5f5;
            text-decoration: none;
            width: 100px;

        }
    style>
head>
<body>
<input id="new_input_1" type="tel" maxlength="1" class="inp1"><br>
<input id="new_input_2" type="tel" maxlength="1" class="inp1"><br>
<input id="new_input_3" type="tel" maxlength="1" class="inp1"><br>
<input id="new_input_4" type="tel" maxlength="1" class="inp1"><br>
<input id="new_input_5" type="tel" maxlength="1" class="inp1"><br>
<input id="new_input_6" type="tel" maxlength="1" class="inp1"><br>
<a id="sub" class="btn1" >提交a>

    <script type="text/javascript" src="jquery-2.1.4.min.js">script>
    <script type="text/javascript" src="bootstrap.min.js">script>
<script>
    var a=$("#new_input_1");
    var b=$("#new_input_2");
    var c=$("#new_input_3");
    var d=$("#new_input_4");
    var e=$("#new_input_5");
    var f=$("#new_input_6");

    $("input").on("keyup",function(){
        var mb=a.val().trim().length && b.val().trim().length && c.val().trim().length && d.val().trim().length && e.val().trim().length && f.val().trim().length;
        if(mb){
          //  alert(aa);
//            alert($(this).val());
            $("#sub").css({
                "background":"#e34f49",
                "color":"#fff",
                "border-bottom":".3rem solid #cd322c"
            });
        }else{
            $("#sub").css({
                "background":"#f5f5f5",
                "color":"#999",
                "border-bottom":".3rem solid #bbb"
            });
        }
    });


script>

body>
html>

你可能感兴趣的:(HTML,CSS,JS技术问题)