Wednesday, December 5, 2012

Jquery Toggle with id, class and paragraph


$('#divtoggle').toggle();

Toggle the elements with id "divtoggle"

$(".test").toggle();
Toggle the elements with class "test"

$("p").toggle();
Toggle the elements with "p"

<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 () {
        $('#btnClick').click(function () {
            $('#divtoggle').toggle("slow");
            $(".test").toggle("slow");
            $("p").toggle("slow");
        });
    });

</script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
 
    <input type="button" id="btnClick" value="+" />
     <h2 class="test">This is a heading</h2>
    <div id="divtoggle">
    I am a Toggle panel
    </div>
    <p>I am a paragraph</p>
    </form>
</body>
</html>

No comments:
Write comments
Recommended Posts × +