V Posted July 9, 2010 Share Posted July 9, 2010 I have a text that when click a a HTML form slides down. I'm trying to slide it back up when you click on the text again. The code that works is <script type="text/javascript"> $(document).ready(function(){ $("#slidedown").click(function() { $("#form").slideDown("fast"); }); }); </script> and now to slide it back up on click I tried toggle. Nothing happens tho.. <script type="text/javascript"> $('#slidedown').toggle( click(function() { $('#form').slideDown("fast"); }), click(function() { $('#form').slideUp("fast"); }); ); </script> Please anyone have any suggestions? Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/ Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 It appears you are missing the # hashs from the 'form' selectors. Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083319 Share on other sites More sharing options...
V Posted July 9, 2010 Author Share Posted July 9, 2010 Throbe, sorry it was a typo I made when posting. The code orginally has the # but doesn't work Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083323 Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 Copy and Paste your actual code. We need your markup as well. Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083326 Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 Those clicks don't belong there. $('#slidedown').toggle( function() { $('#form').slideDown("fast"); }), function() { $('#form').slideUp("fast"); }); ); Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083327 Share on other sites More sharing options...
V Posted July 9, 2010 Author Share Posted July 9, 2010 Thanks throbe I tried without clicks but again nothing happens. This is the page code I use <div id="slidedown">+ Add New Category</div> <div id="form"> <form action="#" method="post"> <input type="text" id="cat" name="cat" size="14" /> <br /> <input type="submit" name="submit" id="button" class="submit" value="Add Category"> </form> </div> It works fine just sliding down. Sliding back up is the issue.. Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083330 Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 There was a few syntax errors. $(document).ready(function() { $('#slidedown').toggle( function() { $('#form').slideDown("fast"); }, function() { $('#form').slideUp("fast"); } ); }); Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083331 Share on other sites More sharing options...
V Posted July 9, 2010 Author Share Posted July 9, 2010 Thanks Thrope! It works perfectly now. Sometimes I consider JS way too compliocated and I overlook the minor errors.. Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083336 Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 Make sure you have firebug installed within FF and get a decent editor. Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083339 Share on other sites More sharing options...
V Posted July 9, 2010 Author Share Posted July 9, 2010 Will do! Thanks again! Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083342 Share on other sites More sharing options...
isedeasy Posted July 9, 2010 Share Posted July 9, 2010 untested but this should also work $(document).ready(function() { $('#slidedown').click( function() { $('#form').slideToggle("fast"); } ); }); Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083575 Share on other sites More sharing options...
V Posted July 9, 2010 Author Share Posted July 9, 2010 untested but this should also work $(document).ready(function() { $('#slidedown').click( function() { $('#form').slideToggle("fast"); } ); }); Yes that works too Thanks! Link to comment https://forums.phpfreaks.com/topic/207197-jquery-on-second-click/#findComment-1083646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.