I have been working on creating a website that allows users to download PDF and MP3 files of sermons. However, I am facing challenges in implementing a dropdown menu for this functionality.
Despite searching resources like Bootstrap and W3schools, I have not been able to find a solution.
<script>
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
<li>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson </button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson </button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson 3</button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson 4</button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson 5</button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
<ul>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Lesson 6</button>
<div id="myDropdown" class="dropdown-content">
<a href="#" download>Lesson PDF</a>
<a href="#" download>MP3 File</a>
</div>
</div>
</ul>
</li>
This is the current state of my progress, but it does not meet my expectations.