事件代理
let ul = document.getElementsByTagName("ul")[0]
let lis = document.getElementsByTagName("li")
ul.onclick = function (e) {
var e = e || window.event
var target = e.target || e.srcElement
if (target.nodeName == "LI") {
// let index = Array.prototype.indexOf.call(lis,target)
let index = Array.from(lis).indexOf(target)
console.log(index)
target.style.background = 'red';
}
}