<!DOCTYPE html>
<html>
<head>
<style>
.mystyle {
width: 300px;
height: 50px;
text-align: center;
background-color: coral;
color: white;
margin-bottom: 10px;
}
</style>
</head>
<body>
<p>该实例中,我们在文档中查找第一个 div 元素。如果该 div 元素的 id 等于 "myDIV" 修改其字体大小。</p>
<div id="myDIV" class="mystyle">
I am a DIV element
</div>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementsByTagName("DIV")[0];
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。