How to toggle (hide / show) sidebar div using jQuery
How to toggle (hide / show) sidebar div using jQuery
I have 2 The layout looks like diagram below; The styling is like below; I have How can I get this done using jQuery? See this fiddle for a preview and check the documentation for jquerys toggle and animate methods. Basically you animate on the properties that sets the layout. A more advanced version: This stops the previous animation, clears animation queue and begins the new animation. and in the CSS: You can also see any animated version at http://jsfiddle.net/hThGb/2/ This help to hide and show the sidebar, and the content take place of the empty space left by the sidebar. Instead #sidebar give the id of ur div.A
and B
. div A
has a fixed width, which is taken as a sidebar. html, body { margin: 0; padding: 0; border: 0; } #A, #B { position: absolute; } #A { top: 0px; width: 200px; bottom: 0px; } #B { top: 0px; left: 200px; right: 0; bottom: 0px; }
toggle
which acts as a toggle button. On the toggle button click, the sidebar may hide to the left and div B
should stretch to fill the empty space. On second click, the sidebar may reappear to the previous position and div B
should shrink back to the previous width.Answer by Kristoffer Sall-Storgaard for How to toggle (hide / show) sidebar div using jQuery
$('#toggle').toggle(function(){ $('#A').animate({width:0}); $('#B').animate({left:0}); },function(){ $('#A').animate({width:200}); $('#B').animate({left:200}); });
$('#toggle').toggle(function(){ $('#A').stop(true).animate({width:0}); $('#B').stop(true).animate({left:0}); },function(){ $('#A').stop(true).animate({width:200}); $('#B').stop(true).animate({left:200}); })
Answer by EMMERICH for How to toggle (hide / show) sidebar div using jQuery
$('#toggle').click(function() { $('#B').toggleClass('extended-panel'); $('#A').toggle(/** specify a time here for an animation */); });
.extended-panel { left: 0px !important; }
Answer by Hussein for How to toggle (hide / show) sidebar div using jQuery
$('button').toggle( function() { $('#B').css('left', '0') }, function() { $('#B').css('left', '200px') })
Check working example at http://jsfiddle.net/hThGb/1/
Answer by S. Mayol for How to toggle (hide / show) sidebar div using jQuery
Answer by Jafar Ali for How to toggle (hide / show) sidebar div using jQuery
$(document).ready(function () { $(".trigger").click(function () { $("#sidebar").toggle("fast"); $("#sidebar").toggleClass("active"); return false; }); });
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment