我正在尝试创建一个网站,可以通过该网站下载讲道的pdf和mp3文件,但由于无法找到下拉菜单的方法,因此无法执行此操作。
我尝试在引导程序,W3schools等上查找它,但无济于事。
<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>
这是我能做的最好的事情,但对我来说还不够。
答案 0 :(得分:0)
答案 1 :(得分:-2)
您可以通过Polymer找到多个组件。
例如:https://www.webcomponents.org/search/dropdown