Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I have selected project from ASP.NET, just go through the code

XML
<script type="text/javascript">
      $(document).ready(function() {
          $("#searchLink").click(function() {
              $("#searchPanel").slideToggle(200);
              $('#txtAWCategory').focus();
              $('#txtAWCategory').val('');
              //                $('#txtpwd').val('');
          })
      });
    </script>


XML
<div style="text-align:right;">
           <a id="searchLink">
                <!--<img src="../images/btn_search.jpg" border="0" title="Search" alt="Search" />-->
                <img src="Images/search.jpg" width="4%" alt="Search"/>
           </a>
            <div id="searchPanel">
                <table>
                <tr>
                    <td>AWCategory</td>
                    <td><asp:TextBox ID="txtAWCategory" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td colspan='2' align='right'><asp:Button ID="btnSearch" runat="server" Text="Go" /></td>
                </tr>
                </table>
                <br />
            </div>
        </div>



Problem is I have used sidetoggle, when I first click on search image the searchPanel get visible but on second click the searchPanel does not hide.

Any solution..??
Thanks in advance
Posted
Updated 21-Dec-10 19:39pm
v2
Comments
Sandeep Mewara 22-Dec-10 2:00am    
I don't see anything wrong as such. Did you try to DEBUG and see the execution path?
Igor Kushnarev 22-Dec-10 2:12am    
I don't see anything wrong too. All works fine. Try
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script>
DaveAuld 22-Dec-10 11:28am    
I just deleted the answer i gave, after trying the code you supplied in the question and found it works just fine.

1 solution

I don't see anything wrong with this, I just pasted in my IDE and all ran fine.

Have you by any chance added custom CSS to initially hide the searchPanel element. Something like...

#searchPanel {
visibility:hidden; // Or display: none;
}

The slidetoggle function works by switching the style of the target element from "display: none;" to "display: block;", if you have other styles trying to control visibility then jQuery can sometimes get confused.

Since you say 'when I first click on search image the searchPanel get visible' then something must be setting it to invisible when the page first loads?

A way to get around this is to set the style inline that jQuery is expecting. Not the most elegant markup, but since we're changing it on the fly anyway it doesn't really matter

<div id="searchPanel" Style="display: none;";>

The search panel will now be invisible on first load, but jQuery slideTogggle will switch from none to block with no problems.




Otherwise as other people have said, nothing wrong with this!!
 
Share this answer
 
v3
Comments
dhage.prashant01 23-Dec-10 5:47am    
Yes i have used CSS
I have display:none for searchPanel

Still its not working
Dylan Morley 23-Dec-10 5:54am    
Try removing the CSS and put the style in-line as above.

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