Wednesday, December 5, 2012

Jquery Show/Hide Example





















.hide()
hide the specified element

.show()
show the specified element

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".ex .hide").click(function () {
            $(this).parent(".ex").hide("slow");
        });
        $(".show").click(function () {
        $(".ex").show("slow");
        });
     });
</script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
 
   <button class="show">Show me All</button>
   <h3>This is Heading 1</h3>

<div class="ex">
<button class="hide" id="btnHide">Hide me</button>

<p>Contact: Chamara, Colombo</p>
</div>
<h3>This is Heading 2</h3>
<div class="ex">
<button class="hide">Hide me</button>

<p>Contact: janaka, Kandy</p>
</div>
</form>
</body>
</html>


No comments:
Write comments
Recommended Posts × +