第九节 JavaScript提取行间事件
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <script type="text/javascript"> 7 window.onload = function(){ 8 var oBtn = document.getElementById('btn01') 9 10 function fnChange(){ 11 var oDiv = document.getElementById('div1'); 12 oDiv.style.color = 'red'; 13 oDiv.style.fontSize = '20px' 14 } 15 oBtn.onclick = fnChange; 16 } 17 18 // fnChange() 19 20 </script> 21 </head> 22 <body> 23 <div id="div1">这是一个div</div> 24 <input type="button" name="" value="改变div" id="btn01"> 25 </body> 26 </html>