Toggle two divs percentage width with one button

天大地大妈咪最大 提交于 2019-12-14 03:22:15

问题


i want to toggle the width of two divs with one button as seen on: http://www.ulrichshusen.de

The menu on top shrinks while the left area is shown. And it expands while the left area isn't shown.

How can i accomplish this with jquery?


回答1:


$(document).ready(function(){
 $('**button class here**').click(function(){
   $('div to be resized').toggle();
   $('div to be resized').toggle();
   )};
});

Here is to add class and remove class

$(document).ready(function(){
 $('**button class here**').click(function(){
   $(this).sibling().removeClass().addClass();
   )};
 });

This should help you get started in the right direction. You will probably need some if statements added and or current states of each, but Christian Varga is correct it would be simple to do .addClass then add the class of what the div state should be. Hope this gets you started.




回答2:


Actually there was no connection between top nav and the button you click to toggle left section. The button only controls left section. I did some work for you to understand. Follow the link below:

http://jsfiddle.net/sanman/LveSp/


来源:https://stackoverflow.com/questions/16302819/toggle-two-divs-percentage-width-with-one-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!