<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
htmlbiaoqian111
</title>
</head>
<body>
<div>1</div>
<div>2</div>
<div>3</div>
<script type="text/javascript">
var aDiv = document.getElementsByTagName('div');
aDiv[0].style.color = 'red';
aDiv[1].style.color = 'green';
aDiv[2].style.color = '#ccc';
</script>
</body>
</html>
id -> document.getElementById('id');
tagName ->标签名 复数
document.getElementsByTagName('tagname');
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
htmlbiaoqian111
</title>
</head>
<body>
<div class="a1">1</div>
<div class="a2">2</div>
<div class="a3d">3</div>
<script type="text/javascript">
var aDiv = document.getElementsByClassName('a1');
aDiv[0].style.color = 'pink';
</script>
</body>
</html>
class-->类
document.getElementByClassName(‘ClassName’);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
htmlbiaoqian111
</title>
</head>
<body>
<div class="a1">1</div>
<div class="a2">2</div>
<div class="a3">3</div>
<script type="text/javascript">
var aDiv = document.getElementsByClassName('a1');
aDiv[0].style.cssText = 'width:300px;height:200px;background:red;color:black';
</script>
</body>
</html>
cssText -> 可以像css那样去写代码
innerHTML 可以帮咱们去改变 html里面的内容
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
htmlbiaoqian111
</title>
</head>
<body>
<div class="a1">1</div>
<div class="a1">2</div>
<div class="a1">3</div>
<script type="text/javascript">
var aDiv = document.getElementsByClassName('a1');
aDiv[0].innerHTML = 'Leo课堂';
setTimeout(function(){
aDiv[1].innerHTML = '今天是1月11日';
},1000);
</script>
</body>
</html>