html页面控制字体大小的js代码

dom对象控制显示文章字体大小的js代码

 1 <head>
 2    
 3     
 4     <script type="text/javascript">
 5     
 6         function check(size){
 7             document.getElementById("mycode").style.fontSize=size+"pt";
 8         }
 9     
10     </script>
11   </head>
12   
13   <body>
14       <div id="mycode">
15           我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,
16       </div>
17       选择字号【 
18       
19       
20       <a href="javascript:check(13)">13pt(超大)</a>
21       <a href="javascript:check(10.5)">10.5pt(中型)</a>
22       <a href="javascript:check(9)">9pt(标准)</a>
23 24   </body>
25 </html>
View Code

 jquery对象,控制显示文章字体的大小的js代码

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10  
11    
12     <script type="text/javascript" src="<%=request.getContextPath()%>/jquery/jquery.js"></script>
13     
14     <script type="text/javascript">
15     
16         function dd(size){
17             
18             $("#long").css("font-size",size+"pt");
19         }
20     
21     </script>
22   </head>
23   
24   <body>
25   
26       <div id="long">
27           龙飞凤舞,舞文弄墨
28       </div>
29       
30  
31  
32  加大字号:<a href="javascript:dd(16)">加大</a>
33   </body>
34 </html>
View Code
原文地址:https://www.cnblogs.com/shangxiaofei/p/3918724.html