Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Thursday, 14 May 2015

Introduction: 

In this article I will explain how to show or hide div when checkbox checked (selected) or unchecked using jQuery in ASP.NET.


Following jQuery Script we will use to Show or Hide Div:

<script type="text/javascript">
    $(function () {
        $('#chkStatus').change(function () {
            if ($('#chkStatus').is(':checked'))
                $("#testdiv").fadeIn();
            else
                $('#testdiv').fadeOut();
        });
    });
</script>

Full Source for Sample Application:

For demo create your web application as given below and check the result.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title> Show or Hide Div on CheckBox click or selection</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        $('#chkStatus').change(function () {
            if ($('#chkStatus').is(':checked'))
                $("#testdiv").fadeIn();
            else
                $('#testdiv').fadeOut();
        });
    });
</script>

</head>
<body>
<form id="form1">
<fieldset style="width:300px">
    <legend><strong> Show or Hide Div on CheckBox Checked</strong></legend>
<div>
How or Hide Div :
<input type="checkbox" id="chkStatus" checked="checked"/>
<br /><br />
<div id="testdiv" style="padding:20px; border:5px solid #fff; width:80%; font-weight:bold;background:#EB5E00;color:#fff;">
Show or Hide Div on CheckBox Checked or selection using jquery  in asp.net.
</div>
</div></fieldset>
</form>
</body>

</html>

0 comments:

Post a Comment