见下方代码:
function renderList(templateInfos) {
var html = str;
for (var i = 0, l = templateInfos.length; i < l; i++) {
if (templateInfos[i].status == 1) {
var buttonName = templateInfos[i].name;
html += ['<li>',buttonName,'</li>'
].join("")
}
}
buttonwrapper.innerHTML = html;
}
function change(){
let searchInputText = document.getElementById('searcher-text');
let value = searchInputText.value;
let newArr = result.filter((arr)=>{ return arr.name.indexOf(value) === -1 ? false : true})
if(!value) renderList(result);
renderList(newArr);
}
网友评论