帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» html列表简单搜寻效果
html列表简单搜寻效果
浏览:735次
-
评论:0次
-
发布时间:2018-07-26
Html
Css
Js
Name
Country
Alfreds Futterkiste
Germany
Berglunds snabbkop
Sweden
Island Trading
UK
Koniglich Essen
Germany
#myInput { background-image:url('/css/searchicon.png'); /* Add a search icon to input */ background-position:10px 12px; /* Position the search icon */ background-repeat:no-repeat; /* Do not repeat the icon image */ width:100%; /* Full-width */ font-size:16px; /* Increase font-size */ padding:12px 20px 12px 40px; /* Add some padding */ border:1px solid #ddd; /* Add a grey border */ margin-bottom:12px; /* Add some space below the input */ } #myTable { border-collapse:collapse; /* Collapse borders */ width:100%; /* Full-width */ border:1px solid #ddd; /* Add a grey border */ font-size:18px; /* Increase font-size */ } #myTable th,#myTable td { text-align:left; /* Left-align text */ padding:12px; /* Add padding */ } #myTable tr { /* Add a bottom border to all table rows */ border-bottom:1px solid #ddd; } #myTable tr.header,#myTable tr:hover { /* Add a grey background color to the table header and on hover */ background-color:#f1f1f1; }
function myFunction() { // Declare variables var input, filter, table, tr, td, i; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { if (td.innerHTML.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>html列表简单搜寻效果-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:html列表自动检索输入内容
透过简单列表搜寻功能,让用户找到列表中相应的资料。
利用模板及正则解决JS拼接HTML代码问题
toast提示效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
735
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值