<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="div1" class="divC"></div>
</body>
</html>
<script>
//获取dom,常见有三种方法,分别是根据标签、根据class和id
var div1=document.getElementById('div1');
console.log(div1);
div1.style.width='300px';
var divC=document.getElementsByClassName('divC');
console.log(divC);
divC[0].style.height='300px';
// [document.getElementsByClassName('divC')]
// [document.getElementById('div1')]
// console.log(document.getElementById('div1'));
// document.getElementById('div1').style.width='300px';
</script>