ES6-ES11易忘笔记
作者:互联网
let 经典案例实践
点击切换背景色案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.item{
width: 100px;
height: 60px;
display: inline-block;
border-radius: 4px;
border: 2px solid #e06ad4;
}
</style>
</head>
<body>
<div class="content">
<h2>点击切换颜色</h2>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script>
const items = document.querySelectorAll('.item')
for(let i = 0; i < items.length; i ++) {
items[i].onclick = function () {
items[i].style.backgroundColor = 'pink'
}
}
</script>
</body>
</html>
rest 参数
function fn (a, b, ...args) {
console.log(a, b, ...args)
}
fn(1,2,3,4)
标签:function,ES6,...,items,args,笔记,let,ES11,border 来源: https://www.cnblogs.com/lwlblog/p/16385490.html