JS實現點擊按鈕實現文字變大變小

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   sp   on   2014   log   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 = 14;
  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">新華網北京11月29日電 中央外事工作會議11月28日至29日在北京召開。會上強調,要高舉和平、發展、合作、共贏的旗幟,統籌國內國際兩個大局,統籌發展安全兩件大事,牢牢把握堅持和平發展、促進民族複興這條主線,維護國家主權、安全、發展利益,為和平發展營造更加有利的國際環境,維護和延長我國發展的重要戰略機遇期,為實現“兩個一百年”奮鬥目標、實現中華民族偉大複興的中國夢提供有力保障。</p>
</body>
</html>

 

JS實現點擊按鈕實現文字變大變小

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.