<!DOCTYPE html>
<html>
<title>编程狮(w3cschool.cn)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://7npmedia.w3cschool.cn/w3.css">
<body>
<div class="w3-container">
<h2>过滤器下拉悬浮</h2>
<p>将鼠标移到下拉列表上,在输入字段中搜索特定的链接.</p>
<div class="w3-dropdown-hover">
<button class="w3-button w3-black">下拉列表</button>
<div class="w3-dropdown-content w3-bar-block w3-card w3-light-grey" id="myDIV">
<input class="w3-input w3-padding" type="text" placeholder="搜索.." id="myInput" onkeyup="myFunction()">
<a class="w3-bar-item w3-button" href="#about">关于</a>
<a class="w3-bar-item w3-button" href="#base">基地</a>
<a class="w3-bar-item w3-button" href="#blog">博客</a>
<a class="w3-bar-item w3-button" href="#contact">联系</a>
<a class="w3-bar-item w3-button" href="#custom">自定义</a>
<a class="w3-bar-item w3-button" href="#support">支持</a>
<a class="w3-bar-item w3-button" href="#tools">工具</a>
</div>
</div>
</div>
<script>
function myFunction() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
div = document.getElementById("myDIV");
a = div.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
txtValue = a[i].textContent || a[i].innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
a[i].style.display = "";