改变节点css和属性
<!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>改变节点css和属性</title>
<style>
.box{
width: 200px;
height: 200px;
border: 1px solid #000;
}
</style>
</head>
<body>
<div class="box" id="box"> </div>
<script>
var obox = document.getElementById('box')
// obox.style.backgroundColor = 'red'
obox.setAttribute('data-n',10)
var n = obox.getAttribute('data-n')
console.log(n);
</script>
</body>
</html>
我是Eric,手机号是13522679763

浙公网安备 33010602011771号