当前位置:网站首页>Write a search box with search tips
Write a search box with search tips
2022-07-24 04:23:00 【InfoQ】
Search box function
Implementation process


var arr = [" China "," Japan "," The United States "," Russia "," Canada "," The British "," Australia "," Spain "," Germany "," Bombay plus "," The Arab "," India "," Indonesia "];var search = document.getElementsByClassName("blue-input")[0];
text Content = search.value- oninput Event triggered on user input .
- onblur Events occur when an object loses focus .
- onfocus Event occurs when the object gets focus .
function searchByIndexOf(keyWord, list){
if(!(list instanceof Array)){ return ; }
if(keyWord == ""){ return []; }else{
var len = list.length;
var arr = [];
for(var i=0;i<len;i++){
// If the string does not contain the target character, it returns -1
if(list[i].indexOf(keyWord)>=0){
arr.push(list[i]);
}
}
return arr;
}
}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="css/common.css" />
</head>
<body>
<div id="container" class="center-justify">
<div class="sea-container">
<form action="">
<input type="text" name="search" class="blue-input" >
<input type="submit" value=" Search for " class="blue-button">
</form>
<p id="selectedId"></p>
</div>
</div>
<script src="js/sreach.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>Realization effect






Reference article
边栏推荐
- Avoid mistakes, common appium related problems and Solutions
- Embedded system transplantation [6] - uboot source code structure
- Good performance and reliability. The parameter that initiates writing IIC co type code and is -4
- 如何用STATA进行chowtest
- 短视频本地生活版块,有哪些新的机会存在?
- 训练数据量不只适用于.z据接收方对数字视
- Successfully solved: error: SRC refspec master doors not match any
- LAN SDN technology hard core insider 10 cloud converged matchmaker evpn
- Traversal of binary tree
- [C language] program environment and preprocessing operation
猜你喜欢

D2DEngine食用教程(3)———将渲染目标导出为图像文件

Once svchost Troubleshooting of exe process occupying a large amount of network bandwidth

64 attention mechanism 10 chapters

postgresql源码学习(32)—— 检查点④-核心函数CreateCheckPoint

PostgreSQL source code learning (32) -- checkpoint ④ - core function createcheckpoint

Smart contract: release an erc20 token

C语言基础学习笔记
[hope to answer] the data cannot be synchronized correctly

D2dengine edible tutorial (3) -- export rendering targets as image files

PMIX ERROR: ERROR in file gds_ ds12_ lock_ pthread.c
随机推荐
What is the product and expressiveness of 113700 Xingrui? Come and have a look
Smart people's game improvement: Chapter 3 Lesson 3 example: the secret of prime
[novice] develop a tab component that is easy to expand by hand
可能有点用的冷知识
buu web
Jinglianwen technology provides 3D point cloud image annotation service
Energy principle and variational method note 11: shape function (a dimension reduction idea)
NFT除了买卖还能质押?
Avoid mistakes, common appium related problems and Solutions
Codeforces Round #809 (Div. 2) A - D1
00cm non, make sure to go online with the business party once in advance, and make everything better
An accident caused by MySQL misoperation, and "high availability" can't withstand it
(008) flask is OK if you have a hand -- database migration flask migrate
C语言经典习题之评委打分去掉最高最低求平均分
别人发的word中的参考文献是{}这样的乱码格式怎么办
如何用STATA进行chowtest
Go language series - synergy GMP introduction - with ByteDance interpolation
1.7.1 正误问题(中缀表达式)
Baidu search cracking down on pirated websites: why Internet content infringement continues despite repeated prohibitions
。 When calling, the incoming t refers to the Devi pass, which basically asks T2,