首页 > 代码库 > 实例1(文字的放大缩小)

实例1(文字的放大缩小)

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <script>
      window.onload = function (){
        var oBtn1 = document.getElementById(‘btn1‘);
        var oBtn2 = document.getElementById(‘btn2‘);
        var oP = document.getElementById(‘p1‘);
        var num = 14;

        oBtn1.onclick = function (){
          num -= 2;
          oP.style.fontSize = num + ‘px‘;
        // JS 不允许出现"-"
        // padding-top paddingTop
        // margin-left marginLeft
        };
        oBtn2.onclick = function (){
        // num = num + 2;
          num += 2;
          oP.style.fontSize = num + ‘px‘;
        // JS 不允许出现“-“
        };
      };
    </script>
  </head>

</html>

实例1(文字的放大缩小)