mardi 11 octobre 2016

I want to click on a check box if checked box is checked than it will hide a div otherwise uncheck show

I am new to jquery. I want to make a functionality. When user click on Yes checkbox a div gets hidden. I am trying to do it but its not working. Please Let me know what mistakes I am doing?

Code as Follows

<html xmlns="http://ift.tt/lH0Osb">
<head runat="server">
    <title></title>
     <script src="../Scripts/jquery-1.8.2.js"></script>
        <link href="../Content/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript">

        function valueChanged() {
            debugger;
            if ($('.chkYes').is(":checked"))
                $("#hidedivs").hide();


        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        <div class="container">
            <div class="row">
                   <div class="col-lg-6">
                       <asp:Label runat="server" ID="lblFirstName" Text="First Name"></asp:Label>
                   </div>
                 <div class="col-lg-6">
                     <asp:TextBox runat="server" ID="txtFname" class="form-control"  placeholder="Enter your First  Name"></asp:TextBox>
                    </div>
               </div>
            &nbsp
             <div class="row">
                   <div class="col-lg-6">
                       <asp:Label runat="server" ID="lblLastName" Text="Last Name"></asp:Label>
                   </div>
                 <div class="col-lg-6">
                     <asp:TextBox runat="server" ID="txtLname" class="form-control"  placeholder="Enter your  Last Name"></asp:TextBox>
                    </div>
               </div>
            &nbsp
             <div class="row" id="hidedivs">
                   <div class="col-lg-6">
                       <asp:Label runat="server" ID="lblAge" Text="Age"></asp:Label>
                   </div>
                 <div class="col-lg-6">
                     <asp:TextBox runat="server" ID="txtAge" class="form-control"  placeholder="Enter your Age"></asp:TextBox>
                    </div>
               </div>
            &nbsp
            <div class="row">
                <div class="col-lg-6">
                    <asp:label runat="server" ID="IsSapApplicable" Text="Is SAP Applicable"></asp:label>
                </div>
                <div class="col-lg-6">
                    <asp:Label runat="server" ID="lblYes" Text="Yes"></asp:Label>
                    <input type="checkbox" id="chkYes"  onchange="valueChanged();" value="1"/>

                     <asp:Label runat="server" ID="lblNo" Text="No"></asp:Label>
                    <input type="checkbox" id="chkNo"/>
                </div>
            </div>
    </div>
    </form>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire