zoukankan      html  css  js  c++  java
  • 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,一开始忘记加引号,导致怎么都出不来。。。

  • 相关阅读:
    C 字符串
    C 函数指针、回调函数
    C 指针
    C 数组、枚举类型enum
    C 函数声明、函数参数
    C 内置函数
    C 流程控制
    C 储存类与运算符
    C变量和常量
    名词解释
  • 原文地址:https://www.cnblogs.com/jin-wen-xin/p/3988155.html
Copyright © 2011-2022 走看看