首页 > 代码库 > web1

web1

 1 <!DOCTYPE html> 2 <html> 3 <head> 4     <title>web0923</title> 5     <script> 6         function displayDate() { 7             document.getElementById("date").innerHTML = Date(); 8         } 9         function changePic() {10             alert("Ah?");11             element = document.getElementById(myImg);12             element.style.color = "#ff0000";13             element.height = "300";14             element.width = "300";15             if (element.src.match("gr+")) {16                 element.src = "LockScreen.jpg";17             }18             else {19                 element.src = "grass.jpg";20             }21         }22     </script>23 </head>24 <body>25     <h1>Title</h1>26     <p>Para</p>27     <div id="abc">28         <p id="date"></p>29         <button type="button" onclick="displayDate()">display date</button>30     </div>31     <div id="image">32         <img id="myImg" src="grass.jpg" width="100" height="100">33         <button type="button" onclick="changePic()">change picture</button>34     </div>35     <div>36         <input id="AccountID" type="text">37         <script>38             function judgeNumber() {39                 var str = document.getElementById("AccountID").value;40                 if (str == "" || isNaN(str)) {41                     alert("This is not a number");42                 }43             }44         </script>45         <button type="button" onclick="judgeNumber()">Submit</button>46     </div>47 </body>48 </html>
View Code


学了很基础的一部分,getElementById("**控件名字**").value,一开始忘记加引号,导致怎么都出不来。。。

web1