Change div's inline width with js


I have a left nav like this I want the right side div automatically adjust its width to 100% when the left nav is expand state or it is in collapse state. Somebody please help me to do this. Thanks in advance.

Assuming you want the green div to reach the right of the viewport then you can do that with css but will have to over-ride the inline js you are applying.



Thanks Paul, Now i am facing another problem :(. Is there any way to keep the menu in it’s sub menu level even it’s in another page. Example. If i click Mobile phones, then i click it’s sub menu Super smart Phone. This is another page. and once it’s refreshing or changing the url the menu is going to its default state from its sub menu level. Is there anyway to stay it in it’s sub menu level when the page is refresh or open another page.

I suspect the easiest way to do this is to use ajax to fetch the content for the main div when clicking around preventing a full reload of the page. This will require some back end work to function, you can use something like pjax to help with loading partial page content.

An alternative is to save the state of the menu when changed in localStorage and then to load the menu to the correct state on page load.

Or, you can include a script on each page to open the menu to the correct place, I don’t know enough about how the menu works to know what this would look like though.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.