On 7 sep, 08:15, mrjoops <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I expect from the following code to display only the submenu of the
> active menu. It works like a charm under Firefox and Opera but not
> under IE (at least under version 7).
> If someone could help, I would appreciate.
>
> Here is the code:
> $(document).ready(function()
> {
>   $("ul").hide();
>   $("ul.level1").show();
>   $("li.active").next("ul").show();
>
> });
>
> Here is the HTML:
> <ul class="level1">
>   <li>menu 1</li>
>   <ul class="level2">
>     <li>submenu 1 - 1</li>
>     <li>submenu 1 - 2</li>
>   </ul>
>   <li class="active">menu2</li>
>   <ul class="level2">
>     <li>submenu 2 - 1</li>
>     <li>submenu 2 - 2</li>
>   </ul>
> </ul>
>

This is not valid html and the "level2"  uls won't even display
without any javascript under IE.

You should instead enclose them in the parent li, such as:

<ul class="level1">
  <li>menu 1
  <ul class="level2">
    <li>submenu 1 - 1</li>
    <li>submenu 1 - 2</li>
  </ul>
</li>
  <li class="active">menu2
  <ul class="level2">
    <li>submenu 2 - 1</li>
    <li>submenu 2 - 2</li>
  </ul>
</li>
</ul>


and then use $("li.active ul").show(); to display it.

Regards,
Renaud Drousies

Reply via email to