前言

html+JS实现点击按钮实现文字持续变大变小实例

实例代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script>
 window.onload = function(){
  var oBnt1 = document.getElementById('bnt1');
  var oBnt2 = document.getElementById('bnt2');
  var oP = document.getElementById('text');
  var num = 16;
  oBnt1.onclick = function(){
   num --;
   oP.style.fontSize = num+'px';
  }
  oBnt2.onclick = function(){
   num ++;
   oP.style.fontSize = num+'px';
  }

 }
</script>
</head>
 
<body>
    <input id="bnt1" type="button" value="-" />
    <input id="bnt2" type="button" value="+" />
    <p id="text">萝卜白菜<br>红萝卜,大白菜,红的红来白的白。吃萝卜,吃白菜,圆圆的脸儿真可爱。</p>
</body>