首页 > 代码库 > CSS(三)

CSS(三)

CSS又上完了,真是快!!!

预习了JS的一部分,写了几条简单的JS代码:

1.成绩判定:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生成绩评定</title>
    <script type="text/javascript">
        var a = window.prompt("朋友,请输入你的成绩:");
        if (a==null){
            document.write("拜拜");
        }else if (a>100) {
            document.write("还能愉快的玩耍嘛!!!");
        }else if(a>90) {
            document.write(a+"是优秀");
        }else if (a>=80) {
            document.write(a+"是良好");        
        }else if (a>=70) {
            document.write(a+"是中等");
        }else if (a>=60) {
            document.write(a+"是及格");
        }else if (a<60 && a>=0) {
            document.write(a+"是不及格");
        }else{
            document.write("一脸懵逼");    
        }
    </script>
</head>
<body>
    
</body>
</html>

2.判断平年还是闰年:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>平年还是闰年?</title>
    <script type="text/javascript">
        var a = window.prompt("请输入年份");
        if (a==null) {
            document.write("玩我呢?");
        }else if(a==0){
            document.write("你什么时候听说过0年?");
        }else{
            a%4==0 && a%100!=0 || a%400==0?document.write(a+"年是闰年"):document.write(a+"年是平年");    
        }
    </script>
</head>
<body>
    
</body>
</html>

3.输出1-100内的奇数:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>while</title>
    <script type="text/javascript">
        var i=1;
        while (i<=100) 
        {
            if (i%2!=0) 
            {
            document.write(i+<br>);
            }    
            i++;
        }
    </script>
</head>
<body>
    
</body>
</html>

 

CSS(三)