Fixed search method
This commit is contained in:
parent
fc67642d10
commit
c25d983a02
@ -3,7 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"start": "parcel ./src/index.html -p 4500 --open ",
|
||||
"start": "parcel src/index.html -p 4500 --open ",
|
||||
"build": "parcel build ./src/index.html --public-url /cg-select/",
|
||||
"deploy": "gh-pages -d dist",
|
||||
"predeploy": "npm run build"
|
||||
|
@ -758,16 +758,21 @@ export class DropDown {
|
||||
|
||||
input.oninput = function () {
|
||||
let val = this.value.trim();
|
||||
let anyMatch = false;
|
||||
|
||||
if (val != '') {
|
||||
searchSelect.forEach((elem) => {
|
||||
let isMatching = new RegExp(val, 'gi').test(elem.textContent);
|
||||
anyMatch = anyMatch || isMatching;
|
||||
|
||||
if (elem.innerText.search(val) == -1) {
|
||||
elem.classList.add('displayHide');
|
||||
result.classList.remove('displayHide');
|
||||
} else {
|
||||
elem.classList.remove('displayHide');
|
||||
}
|
||||
});
|
||||
|
||||
result.classList.toggle('displayHide', anyMatch);
|
||||
} else {
|
||||
searchSelect.forEach((elem) => {
|
||||
elem.classList.remove('displayHide');
|
||||
|
Loading…
Reference in New Issue
Block a user