在html中怎么用if判断3秒后执行style="background:#000;"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 200px;
height: 200px;
background-color: aqua;
}
</style>
</head>
<body>
<!--
在html中怎么用if判断3秒后执行style="background:#000;"
-->
<div></div>
<script>
const divEle = document.querySelector('div');
let timer = false;
setTimeout(() => {
timer = true;
if (timer) {
divEle.style.background = "#000";
}
}, 3000);
</script>
</body>
</html>
```
setTimeout(' a()', 3000);
function {
divEle.style.background = "#000";
}