标签:title elements name 内存地址 log tag ESS nsa cli
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
{{message}}
<button>点击1</button>
<button>点击2</button>
<button>点击3</button>
<button>点击4</button>
<button>点击5</button>
</div>
<script src="../vue.js"></script>
<script>
var btns = document.getElementsByTagName(‘button‘)
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener(‘click‘, function () {
console.log(‘按钮‘, i, ‘被点击了‘)
})
}
for (let n = 0; n < btns.length; n++) {
btns[n].addEventListener(‘click‘, function () {
console.log(‘按钮‘, n, ‘被点击了‘)
})
}
</script>
</body>
</html>
标签:title elements name 内存地址 log tag ESS nsa cli
原文地址:https://www.cnblogs.com/ch2020/p/14824077.html