prevent the action happen twice
<p>i made a small menu with <code>&lt;ul&gt;</code> <code>&lt;li&gt;</code>:</p>

<p><strong>js:</strong></p>

<pre><code>$('#ulAcoesCliente li').click(function(ev) {
    $(".ulNone").each(function(){
        if($(this).css("display") == "block"){
            $(this).hide('slow');
        }
    });
    $(this).find('&gt;ul').toggle('slow');
    ev.stopPropagation();
});
</code></pre>

<p>the each get any menu aready opened, close and open where the user click, like a accordeon ( one at a time ).</p>

<p>but if i click in the same, the event will happen twice.</p>

<blockquote>
  <ol>
  <li><p>will close the current sub-menu</p></li>
  <li><p>will open again.</p></li>
  </ol>
</blockquote>

<p>how can i prevent that to happen ?</p>

<p>i accept any tips to make this event more better/<strong>intelligent</strong>.</p>

<p>Thansks</p>

<p>edit:</p>

<p>html as required</p>

<pre><code>                              &lt;ul id="ulAcoesCliente"&gt;
                                    &lt;li&gt;
                                        &lt;button style="font-size: 9px;" id="optComentario"&gt;Comentario&lt;/button&gt;
                                        &lt;ul class='ulNone' style="display: none;"&gt;
                                            &lt;li&gt;
                                                &lt;button style="font-size: 9px; width: 150px;" id="liInserirComentario"&gt;Inserir comentario&lt;/button&gt;
                                                &lt;ul style="display: none;"&gt;
                                                    &lt;li&gt;
                                                        &lt;div style="margin-left: 10px;padding: 5px;"&gt;
                                                            &lt;input id="comentario" type="text" size="20"/&gt;
                                                            &lt;button style="font-size: 9px; width: 60px;" id="butInsereComent"&gt;Salvar&lt;/button&gt;
                                                        &lt;/div&gt;
                                                    &lt;/li&gt;
                                                &lt;/ul&gt;
                                            &lt;/li&gt;
                                            &lt;li style="margin-top: 3px;"&gt;&lt;button style="font-size: 9px; width: 150px;" id="listaComent"&gt;Listar comentarios&lt;/button&gt;&lt;/li&gt;
                                        &lt;/ul&gt;
                                    &lt;/li&gt;
                                    &lt;li&gt;
                                        &lt;button style="font-size: 9px; margin-top: 3px;" id="OptEmail"&gt;E-mail&lt;/button&gt;
                                        &lt;ul class='ulNone' style="display: none;"&gt;
                                            &lt;li style="margin-top: 5px;"&gt;&lt;button style="font-size: 9px; width: 150px;" id="enviaEmail"&gt;Enviar E-mail&lt;/button&gt;&lt;/li&gt;
                                            &lt;li style="margin-top: 3px;"&gt;&lt;button style="font-size: 9px; width: 150px;" id="listaEmails"&gt;Listar E-mails&lt;/button&gt;&lt;/li&gt;
                                        &lt;/ul&gt;
                                    &lt;/li&gt;
                                    &lt;li&gt;
                                        &lt;button style="font-size: 9px; margin-top: 3px;" id=""&gt;Tarefa&lt;/button&gt;
                                        &lt;ul class='ulNone' style="display: none;"&gt;
                                            &lt;li style="margin-top: 5px;"&gt;&lt;button style="font-size: 9px; width: 150px;" id=""&gt;Criar Tarefa&lt;/button&gt;&lt;/li&gt;
                                            &lt;li style="margin-top: 3px;"&gt;&lt;button style="font-size: 9px; width: 150px;" id=""&gt;Listar Tarefas&lt;/button&gt;&lt;/li&gt;
                                        &lt;/ul&gt;
                                    &lt;/li&gt;
                                &lt;/ul&gt;
</code></pre>

<p><strong>edit 2:</strong></p>

<p>i reach this: ( <strong>@Jayendra</strong>, did the same )</p>

<p>but the second level, close.</p>

<pre><code>     if(!($(this).children('ul').css("display") == "block")){
        $(".ulNone").each(function(){
            if($(this).css("display") == "block"){
                $(this).stop(true,true).hide('slow');
            }
        });
        $(this).find('&gt;ul').stop(true,true).toggle('slow');
        ev.stopPropagation();
    }
</code></pre>
