我想用js改变页面的里的文字的字体和字体大小应该怎么处理啊?麻烦各位帮忙看看我应该怎么做。我现在用的解决文字大小的代码:求选择字体的方法,麻烦各位帮忙看看我应该怎么做。请尽量详细一点,我是菜鸟啊,先谢谢各位了。
<select id='id2' onchange='NYSfont()'><option>选择字体
<script language=javascript>
for (i=9;i<200;i++)
{document.write("<option value="+i+">"+i+"pt字体\n");}
function NYSfont()
{if((fontslt.selectedIndex!=-1) && (fontslt.selectedIndex!=0)){readcontent.style.fontSize=fontslt.options[fontslt.selectedIndex].value;}}
</script></select>
<textarea id='id4' rows="15" cols="100">字体大小变化</textarea> 
 
 

解决方案 »

  1.   


    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <style type="text/css">
    #id4{
    width:500px;
    height:300px;
    }
      </style>
      <script type="text/javascript">
      <!--
    function NYSfont()
    {
    var fontslt = document.getElementById("id2");
    var readcontent = document.getElementById("id4");
    if((fontslt.selectedIndex!=-1) && (fontslt.selectedIndex!=0)){readcontent.style.fontSize=fontslt.options[fontslt.selectedIndex].value;}
    }
      //-->
      </script>
     </head> <body>
      <select id='id2' onchange='NYSfont()'><option>选择字体
    <script language=javascript>
    for (i=9;i<200;i++) {
    document.write("<option value="+i+">"+i+"pt字体\n");
    }
    </script>
    </select>
    <textarea id='id4' rows="15" cols="100">字体大小变化</textarea> 
     </body>
    </html>
      

  2.   

    obj.style.fontFamily = "宋体";
    改变字体 .