Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have written jQuery code to slideDown the div elements, but it is not working.

Please tell me what is the error in my code. If not, suggest me to write in another way.
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmJqueryEvents.aspx.cs" Inherits="FrmJqueryEvents" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="jquery-1.8.3.min.js" type="text/javascript"></script>
    <title>Jquery Events</title>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#SlideToDown").click(function () {
                $("#div5").slideDown("slow");
                $("#div6").slideDown("slow");
                $("#div7").slideDown("slow");
                $("#div8").slideDown("slow");
            });
        });
    </script>
    <style type="text/css">
        #div8, #div7, #div6, #div5
        {
            background-color: #e5eecc;
            border-bottom-style: solid;
            display: none;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server" style="width:100%;height:100%"> 
        <table id="tabl2">
            <tr>
                <td>
                    <button id="SlideToDown" style="background-color: #e5eecc; border-bottom-style: solid;">
                        Click To Slide Down</button>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="div5">
                        Submenu1</div>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="div6">
                        Submenu2</div>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="div7">
                        Submenu3</div>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="div8">
                        Submenu4</div>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
Posted
v6
Comments
Dholakiya Ankit 13-Sep-13 6:38am    
are u getting any error?
Please check my answer... :)
[no name] 13-Sep-13 7:01am    
no dear, getting no error, i had left to code
return false;
resulting to postback the page and giving no result.
Dholakiya Ankit 13-Sep-13 7:04am    
ya i see

1 solution

Problem

It will work if you return false from the Button Click Event. Otherwise it posts back giving you no result.


Solution

Return false from the Button Click Event.
XML
<script type="text/javascript">
    $(document).ready(function () {
        $("#SlideToDown").click(function () {
            $("#div5").slideDown("slow");
            $("#div6").slideDown("slow");
            $("#div7").slideDown("slow");
            $("#div8").slideDown("slow");

            return false;
        });
    });
</script>



Demo

[Demo] jQuery slideDown() method Example[^].
 
Share this answer
 
Comments
[no name] 13-Sep-13 6:59am    
Wow !!!
Great. Its Working fine.
[no name] 13-Sep-13 6:59am    
Thanks so much.
Most Welcome... :) My Pleasure. :)
Dholakiya Ankit 13-Sep-13 7:04am    
ya tadit bang on answer
Thanks a lot dholakiya ankit... :)

Please up-vote, if you like it... :P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900