To easily accomplish this, simply enclose both of your DIV
elements within a parent div and use a toggle function to add or remove a hidden
class upon button click. Furthermore, you can define the desired CSS styles within the hidden
class.
Here is an example of the HTML structure:
<a id="toggle" href="#">Toggle</a>
<div id="wrapper">
<div id="my-wrapper"></div>
<div id="sidebar-wrapper"></div>
</div>
And here are the corresponding CSS rules:
#my-wrapper {
width: 500px;
}
#sidebar-wrapper {
width: 200px;
}
#wrapper.hidden #my-wrapper {
width: 700px;
}
#wrapper.hidden #sidebar-wrapper {
display: none;
}
In addition, utilize jQuery for the functionality:
$("#toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("hidden");
});
Check out the live example here.