注册
登录
云敏捷实践
清除搜索栏
返回
清除搜索栏
作者:
糖果
发布时间:
2025-04-10 03:28:54 (1月前)
我想清除搜索栏。这个想法是在表格中搜索列表。搜索功能从输入中调用 onkeyup 然后我添加了一个图标橡皮擦来清除输入 onclick (span)。 即使清除输入,搜索仍会显示搜索结果列表。我想通过单击橡皮擦图标返回整个列表。有什么建议吗? ```html function search() { var input, filter, found, table, tr, td, i, j; input = document.getElementById("searchInput"); filter = input.value.toUpperCase(); table = document.getElementById("list"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td"); for (j = 0; j < td.length; j++) { if (td[j].innerHTML.toUpperCase().indexOf(filter) > -1) { found = true; } } if (found) { tr[i].style.display = ""; found = false; } else if (!tr[i].id.match('^tableHeader')) { tr[i].style.display = "none"; } } }; ```
收藏
举报
1 条回复
动动手指,沙发就是你的了!
登录
后才能参与评论