html input框输入文字 出现对应的数据

<!doctype html>

<head>
	<meta charset="UTF-8">
	<title>选择话题</title>
	<meta http-equiv="content-Type" content="text/html; charset=gb2312">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link href="../css/basic.css" rel="stylesheet" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<script src="../js/jquery-2.1.1.min.js"></script>
	<style>
		* {
			font-family: PingFangSC-Medium;
		}
		
		.title {
			margin: 20px 15px 7px !important;
			color: #6d6d72 !important;
			font-size: 15px !important;
		}
		
		.topic-title {
			font-size: 16px;
			font-weight: 400;
		}
		
		.mui-title {
			font-family: PingFangSC-Medium;
			font-size: 18px;
			color: #303030;
			letter-spacing: 0;
			text-align: center;
		}
		
		.mui-bar-nav {
			top: 0;
			-webkit-box-shadow: none;
			box-shadow: none;
		}
		
		.mui-bar {
			-webkit-box-shadow: none;
			box-shadow: none;
		}
		
		.mui-icon {
			color: black;
		}
		
		.mui-placeholder {
			background: #F5F5F5 !important;
			border-radius: 16px !important;
		}
		
		input[type="search"] {
			background: #F5F5F5 !important;
			border-radius: 16px;
		}
		
		.mui-search .mui-placeholder {
			text-align: left;
			margin-left: 4%;
		}
		
		.mui-icon-search::before {
			content: '\e466';
			color: #CCC;
		}
		
		.mui-placeholder span {
			font-size: 14px;
			color: #CCCCCC;
			letter-spacing: 0;
			line-height: 19px;
		}
		
		.mui-table-view::before {
			background: none;
		}
		
		.mui-table-view-cell::after {
			background: none;
		}
		
		.mui-table-view::after {
			background: none;
		}
		
		.mui-bar .mui-icon {
			font-size: 32px;
			position: relative;
			z-index: 20;
			padding-top: 6px;
			padding-bottom: 10px;
		}
	</style>
</head>

<body>
	<script src="../js/mui.min.js"></script>
	<script type="text/javascript">
		mui.init()
	</script>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-closeempty mui-pull-left"></a>
		<h1 class="mui-title">选择话题</h1>
	</header>
	<div class="mui-content">
		<div style="background-color: white;padding-top: 1rem;">
			<div class="mui-input-row mui-search" style="width: 79%;display: inline-block;margin-left: 4%;">
				<input onkeyup="checkContent(this)"  type="search" class="mui-input-clear" placeholder="搜索话题" style="border-radius: 16px;">
			</div>
			<button type="button" class="mui-btn" style="font-size:1rem;width: 15%;display: inline-block; border: 0px; background-color: transparent;">
				取消
			</button>
		</div>
		<ul class="mui-table-view" id="auto_div">
			<!--<li class="mui-table-view-cell">
				<h4 class="topic-title">#大碗宽面</h4>
				<p>1888车主围观</p>
			</li>
			<li class="mui-table-view-cell">
				<h4 class="topic-title">#话题2</h4>
				<p>18车主围观</p>
			</li>
			<li class="mui-table-view-cell">
				<h4 class="topic-title">#话题3</h4>
				<p>888车主围观</p>
			</li>-->
		</ul>
	</div>

	<script>
		//			var value = "大碗宽面";
		//			var value1 = "话题2";
		//			var html = "";
		//			html +=
		//				'<li onclick="to(&#39;' + value + '&#39;)" class="mui-table-view-cell">' +
		//				'<h4 class="topic-title" >#大碗宽面</h4>' +
		//				'<p>1888车主围观</p>' +
		//				'</li>' +
		//				'<li onclick="to1(&#39;' + value1 + '&#39;)" class="mui-table-view-cell">' +
		//				'<h4 class="topic-title">#话题2</h4>' +
		//				'<p>18车主围观</p>' +
		//				'</li>';
		//			$('.mui-table-view').html(html)
		//			var test_list = [html];
		//			var old_value = "";
		//			//自动完成
		//			function AutoComplete(auto, search, mylist) {
		//				if($("#" + search).val() != old_value || old_value == "") {
		//					var autoNode = $("#" + auto); //缓存对象(弹出框)
		//					var carlist = new Array();
		//					var n = 0;
		//					old_value = $("#" + search).val();
		//					for(i in mylist) {
		//						if(mylist[i].indexOf(old_value) >= 0) {
		//							carlist[n++] = mylist[i];
		//						}
		//					}
		//					if(carlist.length == 0) {
		//						autoNode.hide();
		//						return;
		//					}
		//					autoNode.empty(); //清空上次的记录
		//					for(i in carlist) {
		//						var wordNode = carlist[i]; //弹出框里的每一条内容
		//						var newDivNode = $("<div>").attr("id", i); //设置每个节点的id值
		//						newDivNode.html(wordNode).appendTo(autoNode); //追加到弹出框
		//					}
		//				}
		//				//点击页面隐藏自动补全提示框
		//				/*document.onclick = function (e) {
		//				    var e = e ? e : window.event;
		//				    var tar = e.srcElement || e.target;
		//				    if (tar.id != search) {
		//				        if ($("#" + auto).is(":visible")) {
		//				            $("#" + auto).css("display", "none")
		//				        }
		//				    }
		//				}*/
		//			}
		//			$(function() {
		//				old_value = $("#search_text").val();
		//				$("#search_text").focus(function() {
		//					if($("#search_text").val() == "") {
		//						AutoComplete("auto_div", "search_text", test_list);
		//					}
		//				});
		//				$("#search_text").keyup(function() {
		//					AutoComplete("auto_div", "search_text", test_list);
		//				});
		//			});

		function checkContent(obj) {
			var json = [];
			json.push("#话题1");
			json.push("#话题2");
			var html = "";
			var str = $(obj).val();
			var value = ["话题1", "话题2"];
			console.log(str)
			for(var i = 0; i < json.length; i++) {
				if(json[i].indexOf(str) != -1) {
					html +=
						'<li onclick="tob(&#39;' + value[i] + '&#39;)" class="mui-table-view-cell">' +
						'<h4 class="topic-title">' + json[i] + '</h4>' +
						'<p>1888车主围观</p>' +
						'</li>';
				}
			}
			$("#auto_div").html(html);

		}
		/*$("#search_text").keyup(function() {
			
		});*/

		function tob(value) {
			var searchUrl = encodeURI("newtopic.html?valus=" + value);
			window.location.href = searchUrl;
		}

		$(function() {
			var value = "话题1";
			var value1 = "话题2";
			var html = "";
			html +=
				'<li onclick="to(&#39;' + value + '&#39;)" class="mui-table-view-cell">' +
				'<h4 class="topic-title">#话题1</h4>' +
				'<p>1888车主围观</p>' +
				'</li>' +
				'<li onclick="to1(&#39;' + value1 + '&#39;)" class="mui-table-view-cell">' +
				'<h4 class="topic-title">#话题2</h4>' +
				'<p>18车主围观</p>' +
				'</li>';
			$('.mui-table-view').html(html)
		})

		function to(value) {
			var searchUrl = encodeURI("newtopic.html?valus=" + value);
			window.location.href = searchUrl;
		}

		function to1(value1) {
			var searchUrl = encodeURI("newtopic.html?valus=" + value1);
			window.location.href = searchUrl;
		}
	</script>
</body>
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值