coupe-r Posted July 22, 2011 Share Posted July 22, 2011 Hi All, I just want a div to toggle when clicked. However, when I click it for the first time, it slides down too far, then jumps back up really quick to where it should be. When I click it again, it slides up perfectly? Jquery: <script type="text/javascript"> $(document).ready(function() { $('#personal').click(function() { $('#personalContent').toggle(1000) }); }); HTML: <div id="personal" class="dashHeading"> <p><img src="../img/dashboard/arrow.png" width="20" height="20" /> Personal Information</p> </div> <div id="personalContent" style="display:none;"> <p>This text slides</p> </div> Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/ Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 the only thing that I notice is that you aren't ending you code line <script type="text/javascript"> $(document).ready(function() { $('#personal').click(function() { $('#personalContent').toggle(1000); // place a ; on the end here }); }); other thatn that, I really don't see anything that would be causing this Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246274 Share on other sites More sharing options...
coupe-r Posted July 22, 2011 Author Share Posted July 22, 2011 Thanks for responding, however that wasn't it.... toggle() by itself works fine, but toggle(1000), fadeIn(1000), etc always makes the area bigger and then snaps back about a 1/8 of an inch. Weird.... Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246278 Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 when a duration is provided in the toggle() funciton, it becomes an animation method which affects height and width...here's some interesting reading on the subject.. http://api.jquery.com/toggle/ Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246281 Share on other sites More sharing options...
coupe-r Posted July 22, 2011 Author Share Posted July 22, 2011 OK cool, can you help with a fade question? Below is my fadeIn() code. On clicking a div, it fades in. What I want to do is have it fade out on a second click. Thanks $(document).ready(function() { $('#employment').click(function() { $('#employmentContent').fadeIn('slow', function() {; }); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246289 Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 you want the fadeToggle() function then Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246291 Share on other sites More sharing options...
coupe-r Posted July 22, 2011 Author Share Posted July 22, 2011 Thats perfect!! No need to worry about the height issue anymore... Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/242646-simple-toggle-issue/#findComment-1246295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.