Task description
L Upgrade based on task IV
L change the new element input box from input to textarea
l Allow batch input of multiple content, format can be number, Chinese, English, etc., can be used by carriage return, comma (full-width half-width can be), comma, space (full-width half-width, tab, etc.) and other symbols as different content interval
L Add a query text input box, and a Query button, when you click on the query, the query words in the content of each element to do fuzzy matching, the match to the content of the special identification, such as text color. For example, the content has ABCD, the query word is AB or BC, then the content needs to identify
<textarea> tags define multiple lines of text input controls
<id= "num" name= "num" rows= "" cols ="" ></ textarea >
Enter multiple content, multiple symbol intervals.
Stringobject.split (Separator,howmany) can be used to split a string. Separator can be
A string or regular expression, with a carriage return, a comma, a comma, and an empty number for segmentation, is naturally used in regular expressions. Here is a regular quick look at the table: http://www.jb51.net/shouce/jquery1.82/regexp.html
Enter: \ r; comma:, comma:, empty number: \s;
Num.split (/[,\s, \r]/);
Let num = document.getElementById ("num"). Value; var arr=[]; = Num.split (/[,\s, \r]/); for (Let i = 0;i<arr.length;i++) { // corresponding data processing }
When you click on a query, the query words are blurred in the content of each element.
First, make a query input box and button
<name= "SearchText" rows= " cols=" " ></textarea><id= "Search" > Query </button>
The event is then bound to the Query button, and the event can be queried to see if there is a matching unit in Li.
Search.addeventlistener ("click",function() { = searchtext.value; for (Let i= 0;i<data.length;i++) { if(data[i].search (text) ===0) { = "Yellow" ; } }});
Complete code: https://github.com/moeeliu/ife/blob/master/js6.html
JavaScript arrays, string-related operations