当您单击右侧不同大小的字母时,我希望能够更改字体大小。如何使用 javascript 命令站点执行此操作?这是我到目前为止的代码:
<!DOCTYPE html>
<html>
<head>
<body>
<div>
<font size="2"><a href="javascript:void(0);" onclick="changemysize(16);">A</a></font>
<font size="4"><a href="javascript:void(0);" onclick="changemysize(20);">A</a></font>
<font size="5"><a href="javascript:void(0);" onclick="changemysize(25);">A</a></font>
</div>
<div id="callout" class="medium">
<ul id="controls">
<li id="small">A</li>
<li id="medium">A</li>
<li id="large">A</li>
</ul>
<div id="mymain">
<h1>Header</h1>
<h2>Subheader</h2>
<p>Lorem ipsum dolor sit amet, pri ne periculis definiebas, habeo gloriatur has id. Ius ad ubique animal, eum recteque electram explicari no, sed in nostrum adipiscing. Lorem ipsum dolor sit amet, pri ne periculis definiebas, habeo gloriatur has id.</p>
</div>
</div>
<p style="margin-top: 100px; text-align: center; font-size: 75%;"><a href="../resize.zip">Download the files (resize.zip)</a>
</p>
<script src="resize.js"></script>
</body>
</head>
</html>
Javascript:
function changemysize(myvalue) {
var div = document.getElementById("mymain");
div.style.fontSize = myvalue + "px";
}