28-30 js 文本全選
阿新 • • 發佈:2018-07-01
進行 var spa ML one += item lis pin
要點:使用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 文本全選