JQuery第一章js 上机+课后
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JQuery第一章js 上机+课后相关的知识,希望对你有一定的参考价值。
-
=============上机1 包含字母
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>sj1.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
document.write("在以下字符中:");
-
var count=0;
-
var fruit=["America","Greece","Britain","Canxda","China","Egypt"];
-
for(var i in fruit){
-
document.write(fruit[i]+"<br/>");
-
if(fruit[i].indexOf("a")!=-1||fruit[i].indexOf("A")!=-1){
-
count++;
-
}
-
}
-
document.write("共有"+count+"字符串中包含a或A");
-
</script>
-
</head>
-
-
<body>
-
-
</body>
-
</html>
-
-
-
================
-
===============上机2‘程序调试
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>sj2.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
var t=prompt("请输入一个整数","");
-
if(t<=24){
-
if(t>=12&&t<=18){
-
document.write("下午好,歡迎來到貴美");
-
}else if(t>=19&&t<=23){
-
document.write("晚上好,歡迎來到貴美");
-
}else{
-
document.write("上午好,歡迎來到貴美");
-
}
-
}else{
-
document.write("你輸入的時間不對")};
-
</script>
-
</head>
-
-
<body>
-
-
</body>
-
</html>
-
==================’
-
=============上机3 小型计算器
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>sj3.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
var o1=prompt("請輸入第一個數","");
-
var o2=prompt("請輸入第2個數","");
-
var ys=prompt("請輸入運算符","");
-
var p1=parseInt(o1);
-
var p2=parseInt(o2);
-
switch(ys){
-
case "+":
-
var result=p1+p2;
-
alert(p1+"+"+p2+"="+result);
-
break;
-
case "-":
-
var result=p1-p2;
-
alert(p1+"-"+p2+"="+result);
-
break;
-
case "*":
-
var result=p1*p2;
-
alert(p1+"*"+p2+"="+result);
-
break;
-
case "/":
-
var result=p1/p2;
-
alert(p1+"/"+p2+"="+result);
-
break;
-
}
-
-
</script>
-
</head>
-
-
<body>
-
-
</body>
-
</html>
-
===================
-
=================上机4计算科目分数
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>sj4.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
var sum=0;
-
var p1=prompt("請輸入考試科目數量","");
-
if(p1==0||p1<0){
-
alert("輸入的考试科目无效");
-
}else if(isNaN(p1)){
-
alert("输入的不是数字");
-
}
-
else{
-
for(var i=1;i<=p1;i++){
-
var score=prompt("请输入第"+i+"门科目成绩","");
-
if(score<0){
-
alert("成绩不能是负数");
-
break;
-
}else if(isNaN(score)){
-
alert("成绩必须是数字");
-
break;
-
}else
-
sum+=parseFloat(score);
-
}
-
-
}
-
if(sum!=0)
-
alert(p1+"门科目的总成绩是:"+sum);
-
-
-
</script>
-
</head>
-
-
<body>
-
</body>
-
</html>
-
================
-
======课后3打印金字塔直线
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>kh3.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
-
<script type="text/javascript">
-
document.write("<h3>打印倒正金字塔直线");
-
var i=61;
-
while(i>0){
-
-
document.write("<hr width="+i+"%/>");
-
i=i-10;
-
}
-
for(var j=0;j<70;j=j+10){
-
document.write("<hr width="+j+"%/>");
-
}
-
</script>
-
</head>
-
-
<body style="text-align:center;">
-
-
</body>
-
</html>
-
=======
-
================课后4邮箱地址
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>ke4.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
var email=prompt("请输入正确的邮箱地址:","[email protected]");
-
var index=email.indexOf("@");
-
if(index!=-1&&email.indexOf(".")!=-1){
-
if(index==0){
-
alert("邮箱名称不能为空");
-
}else{
-
-
var name=email.substring(0, index);
-
alert("邮箱地址正确,邮箱名称是:"+name);
-
}
-
}
-
else{
-
-
alert("邮箱地址必须含有@和.");
-
}
-
-
</script>
-
</head>
-
-
<body>
-
-
</body>
-
</html>
-
============
-
=============上机5
-
<!DOCTYPE html>
-
<html>
-
<head>
-
<title>kh5.html</title>
-
-
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-
<meta http-equiv="description" content="this is my page">
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
-
<script type="text/javascript">
-
var i=prompt("请输入今天是星期几","");
-
switch(i){
-
case "星期一":
-
alert("新的一周开始 了");
-
break;
-
case "星期二":
-
alert("努力工作");
-
break;
-
case "星期三":
-
alert("努力工作");
-
break;
-
case "星期四":
-
alert("努力工作");
-
break;
-
case "星期五":
-
alert("明天就是周末了");
-
break;
-
default:
-
alert("放松的休息");
-
break;
-
}
-
-
</script>
-
</head>
-
-
<body>
-
-
</body>
-
</html>
-
以上是关于JQuery第一章js 上机+课后的主要内容,如果未能解决你的问题,请参考以下文章