javascript改字體大小的方法:首先創(chuàng)建一個HTML示例文件;然后定義一些文本內(nèi)容;最后通過“ps[i].style.fontSize="12px";”方式改字體大小即可。
本文操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版,DELL G3電腦
javascript怎么改字體大???
很簡單,代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script language=javascript> window.onload=function(){ var ps=document.getElementById('neirong').getElementsByTagName('span'); for(var i=0;i<ps.length;i++){ ps[i].style.fontSize="12px"; } } </script> </HEAD> <BODY> <div id="neirong"> <p style="line-height: 30pt; text-indent: 32pt;"> <span style="font-size:16px;"> 謝謝! </span> </P> <p style="line-height: 30pt; text-indent: 32pt;"> <span style="font-size:16px;"> 謝謝! </span> </P> <p style="line-height: 30pt; text-indent: 32pt;"> <span style="font-size:16px;"> 謝謝! </span> </P> </div> </BODY> </HTML>
推薦學習:《javascript高級教程》