JQuery第一章js 上机+课后

 

  1. =============上机1 包含字母
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>sj1.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
    <script type="text/javascript">
  13.  
    document.write("在以下字符中:");
  14.  
    var count=0;
  15.  
    var fruit=["America","Greece","Britain","Canxda","China","Egypt"];
  16.  
    for(var i in fruit){
  17.  
    document.write(fruit[i]+"<br/>");
  18.  
    if(fruit[i].indexOf("a")!=-1||fruit[i].indexOf("A")!=-1){
  19.  
    count++;
  20.  
    }
  21.  
    }
  22.  
    document.write("共有"+count+"字符串中包含a或A");
  23.  
    </script>
  24.  
    </head>
  25.  
     
  26.  
    <body>
  27.  
     
  28.  
    </body>
  29.  
    </html>
  30.  
     
  31.  
     
  32.  
    ================

 

 

 

 

 

 

 

 

 

 

 

 

  1.  
    ===============上机2‘程序调试
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>sj2.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
    <script type="text/javascript">
  13.  
    var t=prompt("请输入一个整数","");
  14.  
    if(t<=24){
  15.  
    if(t>=12&&t<=18){
  16.  
    document.write("下午好,歡迎來到貴美");
  17.  
    }else if(t>=19&&t<=23){
  18.  
    document.write("晚上好,歡迎來到貴美");
  19.  
    }else{
  20.  
    document.write("上午好,歡迎來到貴美");
  21.  
    }
  22.  
    }else{
  23.  
    document.write("你輸入的時間不對")};
  24.  
    </script>
  25.  
    </head>
  26.  
     
  27.  
    <body>
  28.  
     
  29.  
    </body>
  30.  
    </html>
  31.  
    ==================’

 

 

 

 

 

  1.  
    =============上机3 小型计算器
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>sj3.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
    <script type="text/javascript">
  13.  
    var o1=prompt("請輸入第一個數","");
  14.  
    var o2=prompt("請輸入第2個數","");
  15.  
    var ys=prompt("請輸入運算符","");
  16.  
    var p1=parseInt(o1);
  17.  
    var p2=parseInt(o2);
  18.  
    switch(ys){
  19.  
    case "+":
  20.  
    var result=p1+p2;
  21.  
    alert(p1+"+"+p2+"="+result);
  22.  
    break;
  23.  
    case "-":
  24.  
    var result=p1-p2;
  25.  
    alert(p1+"-"+p2+"="+result);
  26.  
    break;
  27.  
    case "*":
  28.  
    var result=p1*p2;
  29.  
    alert(p1+"*"+p2+"="+result);
  30.  
    break;
  31.  
    case "/":
  32.  
    var result=p1/p2;
  33.  
    alert(p1+"/"+p2+"="+result);
  34.  
    break;
  35.  
    }
  36.  
     
  37.  
    </script>
  38.  
    </head>
  39.  
     
  40.  
    <body>
  41.  
     
  42.  
    </body>
  43.  
    </html>
  44.  
    ===================

 

 

 

 

 

 

 

 

 

  1.  
    =================上机4计算科目分数
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>sj4.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
    <script type="text/javascript">
  13.  
    var sum=0;
  14.  
    var p1=prompt("請輸入考試科目數量","");
  15.  
    if(p1==0||p1<0){
  16.  
    alert("輸入的考试科目无效");
  17.  
    }else if(isNaN(p1)){
  18.  
    alert("输入的不是数字");
  19.  
    }
  20.  
    else{
  21.  
    for(var i=1;i<=p1;i++){
  22.  
    var score=prompt("请输入第"+i+"门科目成绩","");
  23.  
    if(score<0){
  24.  
    alert("成绩不能是负数");
  25.  
    break;
  26.  
    }else if(isNaN(score)){
  27.  
    alert("成绩必须是数字");
  28.  
    break;
  29.  
    }else
  30.  
    sum+=parseFloat(score);
  31.  
    }
  32.  
     
  33.  
    }
  34.  
    if(sum!=0)
  35.  
    alert(p1+"门科目的总成绩是:"+sum);
  36.  
     
  37.  
     
  38.  
    </script>
  39.  
    </head>
  40.  
     
  41.  
    <body>
  42.  
    </body>
  43.  
    </html>
  44.  
    ================

 

 

 

 

 

 

 

  1.  
    ======课后3打印金字塔直线
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>kh3.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
     
  13.  
    <script type="text/javascript">
  14.  
    document.write("<h3>打印倒正金字塔直线");
  15.  
    var i=61;
  16.  
    while(i>0){
  17.  
     
  18.  
    document.write("<hr width="+i+"%/>");
  19.  
    i=i-10;
  20.  
    }
  21.  
    for(var j=0;j<70;j=j+10){
  22.  
    document.write("<hr width="+j+"%/>");
  23.  
    }
  24.  
    </script>
  25.  
    </head>
  26.  
     
  27.  
    <body style="text-align:center;">
  28.  
     
  29.  
    </body>
  30.  
    </html>
  31.  
    =======

 

 

 

 

 

 

  1.  
    ================课后4邮箱地址
  2.  
    <!DOCTYPE html>
  3.  
    <html>
  4.  
    <head>
  5.  
    <title>ke4.html</title>
  6.  
     
  7.  
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  8.  
    <meta http-equiv="description" content="this is my page">
  9.  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  10.  
     
  11.  
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  12.  
    <script type="text/javascript">
  13.  
    var email=prompt("请输入正确的邮箱地址:","sususan@show.com");
  14.  
    var index=email.indexOf("@");
  15.  
    if(index!=-1&&email.indexOf(".")!=-1){
  16.  
    if(index==0){
  17.  
    alert("邮箱名称不能为空");
  18.  
    }else{
  19.  
     
  20.  
    var name=email.substring(0, index);
  21.  
    alert("邮箱地址正确,邮箱名称是:"+name);
  22.  
    }
  23.  
    }
  24.  
    else{
  25.  
     
  26.  
    alert("邮箱地址必须含有@和.");
  27.  
    }
  28.  
     
  29.  
    </script>
  30.  
    </head>
  31.  
     
  32.  
    <body>
  33.  
     
  34.  
    </body>
  35.  
    </html>
  36.  
    ============

 

 

 

 

 

 

 

 

    1.  
      =============上机5
    2.  
      <!DOCTYPE html>
    3.  
      <html>
    4.  
      <head>
    5.  
      <title>kh5.html</title>
    6.  
       
    7.  
      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    8.  
      <meta http-equiv="description" content="this is my page">
    9.  
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    10.  
       
    11.  
      <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    12.  
      <script type="text/javascript">
    13.  
      var i=prompt("请输入今天是星期几","");
    14.  
      switch(i){
    15.  
      case "星期一":
    16.  
      alert("新的一周开始 了");
    17.  
      break;
    18.  
      case "星期二":
    19.  
      alert("努力工作");
    20.  
      break;
    21.  
      case "星期三":
    22.  
      alert("努力工作");
    23.  
      break;
    24.  
      case "星期四":
    25.  
      alert("努力工作");
    26.  
      break;
    27.  
      case "星期五":
    28.  
      alert("明天就是周末了");
    29.  
      break;
    30.  
      default:
    31.  
      alert("放松的休息");
    32.  
      break;
    33.  
      }
    34.  
       
    35.  
      </script>
    36.  
      </head>
    37.  
       
    38.  
      <body>
    39.  
       
    40.  
      </body>
    41.  
      </html>
    42.  

posted @ 2018-06-30 16:42  H丶  阅读(604)  评论(1编辑  收藏  举报