1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 <style type="text/css"> 7 body { 8 font-size: 12px; 9 } 10 11 fieldset { 12 width: 260px; 13 } 14 15 #tip { 16 margin: 8px 0px; 17 padding: 5px; 18 border: solid 1px #ffdb15; 19 background-color: #ffe6da; 20 color: #666; 21 display: none; 22 } 23 </style> 24 <script type="text/javascript" src="js/system.js"></script> 25 </head> 26 <body> 27 <fieldset> 28 <legend>检测奇偶性</legend> 29 <input type="text" id="txtN"/> 30 <input type="button" value="检测" id="blnC"> 31 32 <div id="tip"></div> 33 </fieldset> 34 <script type="text/javascript"> 35 var time = 1, HTML = ""; 36 $$("blnC").onclick = function () { 37 if (time <= 5) { 38 var $n = $$("txtN").value; 39 if (Number($n)) { //判断是否是数字 40 HTML = ($n % 2) ? "奇数" : "偶数"; 41 } else { 42 HTML = "你输入的不是数字!"; 43 } 44 time++; 45 } else { 46 HTML = "今天你已经超过5次了!"; 47 } 48 $$("tip").style.display = "block"; 49 $$("tip").innerText = HTML; 50 } 51 </script> 52 </body> 53 </html>