1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>无标题文档</title> 6 <script> 7 window.onload = function (){ 8 var oBtn1 = document.getElementById('btn1'); 9 var oBtn2 = document.getElementById('btn2'); 10 var oBtn3 = document.getElementById('btn3'); 11 var oBtn4 = document.getElementById('btn4'); 12 var oP = document.getElementById('p1'); 13 var num = 14; 14 15 oBtn1.onclick = function (){ 16 num -= 2; 17 oP.style.fontSize = num + 'px'; 18 // JS 不允许出现"-" 19 // padding-top paddingTop 20 // margin-left marginLeft 21 }; 22 oBtn2.onclick = function (){ 23 // num = num + 2; 24 num += 2; 25 26 oP.style.fontSize = num + 'px'; 27 // JS 不允许出现"-" 28 }; 29 30 oBtn3.onclick = function (){ 31 // oP.class = 'red'; 32 // class => className 33 oP.className = 'red'; 34 }; 35 oBtn4.onclick = function (){ 36 // oP.class = 'red'; 37 // class => className 38 oP.className = 'yellow'; 39 }; 40 }; 41 </script> 42 <style> 43 .red { 400px; border:10px solid #333; background:red; padding:20px; color:yellow; } 44 .yellow { 500px; border:5px solid #333; background:yellow; padding:10px; color:red; } 45 </style> 46 </head> 47 48 <body> 49 50 <input id="btn1" type="button" value="-" /> 51 <input id="btn2" type="button" value="+" /> 52 <input id="btn3" type="button" value="红" /> 53 <input id="btn4" type="button" value="黄" /> 54 <p id="p1" style="font-size:16px;">10月28日晚,中央纪委监察部官网发布消息,贵州省委常委、遵义市委书记廖少华因涉嫌严重违纪违法接受组织调查。3天后中组部宣布对其免职。廖成为十八大后中纪委一连串"打虎"行动中第十一位落马的副省部级以上高官。</p> 55 56 </body> 57 </html>