I have a set of links that I’m trying to conceal inside a toggle , but my code below is not doing it . Please what have I done wrong.
Thank you.
<script>
$("#navigation li a[id]").click(function()) {
$("#" + this.id.substr(1)).slideToggle(600).siblings('.toggleDiv').slideUp(600);
});
</script>
<div id="search" class="toggleDiv" style="display:none">List</div>
<div id="sidebar">
<ul>
<li><a href="bios.php?id=1">President</a></li>
<li><a href="bios.php?id=2">Vice</a></li>
<li><a href="bios.php?id=3">Secretary</a></li>
</ul>
</div>
Brackets in jQuery are for attributes.
a[id]will not work because thoseatags don’t have anidattribute. You also don’t have a#navigationdiv.Try
$("#sidebar ul li a")