I'm trying to implement a div dropdown menu.
JQuery here:
<script>
$(document).ready(function() {
$('.desplegar').click(function() {
$(this).next("div.desplegar_fills").show().siblings("div.desplegar_fills").hide();
});
});
</script>
I know this jquery would only work to show Subindex level, but I can't even make it work.
HTML here:
<div class="desplegar">
<p>Index 1</p>
<div class="desplegar_fills">
<p>Subindex 1</p>
<div class="desplegar_links">
<a href="#">Enllaç 1</a>
<a href="#">Enllaç 2</a>
<a href="#">Enllaç 3</a>
</div>
</div>
</div>
<div class="desplegar">
<p>Index 2</p>
<div class="desplegar_fills">
<p>Subindex 2</p>
<div class="desplegar_links">
<a href="#">Enllaç 1</a>
<a href="#">Enllaç 2</a>
<a href="#">Enllaç 3</a>
</div>
</div>
</div>
<div class="desplegar">
<p>Index 3</p>
<div class="desplegar_fills">
<p>Subindex 3</p>
<div class="desplegar_links">
<a href="#">Enllaç 1</a>
<a href="#">Enllaç 2</a>
<a href="#">Enllaç 3</a>
</div>
</div>
</div>
It should look like this:
So, if I click on Index 1 it shows Subindex 1 and if i click on Subindex 1 it shows the links. The thing is, if I click on Index 2 or Index 3, Index 1 should close and just display Subindex 2 or Subindex 3(depending on which clicked). Any sugestions? Thanks to everyone!
