Page 1 of 1

CSS menus question

Posted: Sat Mar 08, 2008 7:19 am
by starstuff
Hi,

For days I haven't been able to find the answer to the following problem.

I have a testcase using css menu/AJAX with two levels similar to the one in this example http://www.alistapart.com/articles/horizdropdowns/

I have everything working except for an annoying behavior. When I open a submenu (2nd level) and click on it, by using AJAX the innerHTML field change to whatever text I want but the submenu remains open.

How can I close or refresh the menu/submenu when I click on it?

Re: CSS menus question

Posted: Sat Mar 08, 2008 7:29 am
by bertfour
Better post your code, or put it online somewhere....

Re: CSS menus question

Posted: Sat Mar 08, 2008 8:39 am
by kaszu
Probably to an element you have attached an event listener, so you can use 'this' in that function and

Code: Select all

this.style.display = 'none';

Re: CSS menus question

Posted: Sat Mar 08, 2008 8:56 am
by starstuff
Here is quick example not using AJAX http://www.geocities.com/trifid_sagitarius/index.htm

Click on any 2nd level submenu, the text changes and the menu remains open.

Re: CSS menus question

Posted: Sat Mar 08, 2008 9:36 am
by bertfour
Me thinks your <ul class="submenu"> needs an id as well, so you can close it....

Re: CSS menus question

Posted: Sat Mar 08, 2008 10:41 am
by starstuff
kaszu wrote:Probably to an element you have attached an event listener, so you can use 'this' in that function and

Code: Select all

this.style.display = 'none';
Yep, that did it.

Thanks

[Edit] The only thing left is to reverse the procedure once the submenu disappears.