要点:使用select();
上代码:
if (e.keyCode === 27){ ????????????document.getElementById(‘input‘).select()}//当点击键盘esc键时候,对input框进行全选。
修改样式:
document.getElementById(‘list‘).style = ‘display: none;‘liDom[nowSelectTipIndex].style.backgroundColor=‘green‘
innerHTML:
//将生成内容添加到dom中 ???addContent = function (valueList) { ???????var ul = ‘‘; ????????for (item of valueList) { ???????????ul += `<li>${item}</li>` ????????} ???????document.getElementById(‘list‘).innerHTML = ul; ???};//注意可以有html标签
28-30 js 文本全选
原文地址:https://www.cnblogs.com/yadiblogs/p/9249804.html