I am currently working on a project that involves two divs placed next to each other. My goal is to implement the toggle function in order to collapse one div (Sidebar) horizontally while simultaneously expanding the other (Map) to occupy the full width of the former. After achieving this effect, I aim to have another toggle functionality that will revert both divs back to their original widths and positions. Although I have successfully accomplished the first operation, I am facing difficulties in figuring out how to execute the reverse action. A demonstration can be found at this Fiddle.
$(document).ready(function(){
$("#toggle").click(function(){
$("#sidebar").animate({width: 'toggle'});
$("#map").animate({width: '100%'});
});
});