Notepad++Good Luck To You!

搜索框提示

<style>

#myInput {

    background-image: url('https://static.runoob.com/images/mix/searchicon.png'); /* 搜索按钮 */

    background-position: 10px 12px; /* 定位搜索按钮 */

    background-repeat: no-repeat; /* 不重复图片*/

    width: 100%; 

    font-size: 16px; /* 加大字体 */

    padding: 12px 20px 12px 40px; 

    border: 1px solid #ddd; 

    margin-bottom: 12px; 

}


#myUL {

    /* 移除默认的列表样式 */

    list-style-type: none;

    padding: 0;

    margin: 0;

}


#myUL li a {

    border: 1px solid #ddd; /* 链接添加边框 */

    margin-top: -1px; 

    background-color: #f6f6f6; 

    padding: 12px; 

    text-decoration: none;

    font-size: 18px; 

    color: black; 

    display: block; 

}


#myUL li a.header {

    background-color: #e2e2e2; 

    cursor: default; 

}


#myUL li a:hover:not(.header) {

    background-color: #eee;

}

</style>

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="搜索...">

<ul id="myUL">

  <li><a href="#" class="header">A</a></li>

  <li><a href="#">Adele</a></li>

  <li><a href="#">Agnes</a></li>


  <li><a href="#" class="header">B</a></li>

  <li><a href="#">Billy</a></li>

  <li><a href="#">Bob</a></li>


  <li><a href="#" class="header">C</a></li>

  <li><a href="#">Calvin</a></li>

  <li><a href="#">Christina</a></li>

  <li><a href="#">Cindy</a></li>

</ul>

<script>

function myFunction() {

    // 声明变量

    var input, filter, ul, li, a, i;

    input = document.getElementById('myInput');

    filter = input.value.toUpperCase();

    ul = document.getElementById("myUL");

    li = ul.getElementsByTagName('li');


    // 循环所有列表,查找匹配项

    for (i = 0; i < li.length; i++) {

        a = li[i].getElementsByTagName("a")[0];

        if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {

            li[i].style.display = "";

        } else {

            li[i].style.display = "none";

        }

    }

}


</script>

«    2023年7月    »
12
3456789
10111213141516
17181920212223
24252627282930
31
TOP 搜索
TOP 控制面板
您好,欢迎到访网站!
  查看权限
TOP 最新留言
    TOP 作者列表
    TOP 站点信息
    • 文章总数:163
    • 页面总数:0
    • 分类总数:6
    • 标签总数:20
    • 评论总数:0
    • 浏览总数:312004
    召唤伊斯特瓦尔