javascript - js条件语句console.log 不出结果。

查看:122
本文介绍了javascript - js条件语句console.log 不出结果。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

代码

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javescript">
        var j = 5;
        var l;
        if ( j >= 0 && j <= 60 ) {
            //console.log( "这是E" );
            l = "abcd";
        } else if ( j > 60 && j <= 69 ) {
            console.log( "这是D" );
        } else if ( j > 69 && j <= 78 ) {
            console.log( "这是C" );
        } else {
            console.log( "超神" );
        }
    </script>
</body>
</html>

又修改了一下代码。但是还是打印不出来。

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javescript">
        var j = 5;
        if ( j >= 0 && j <= 60 ) {
            console.log( "这是E" );
        } else if ( j > 60 && j <= 69 ) {
            console.log( "这是D" );
        } else if ( j > 69 && j <= 78 ) {
            console.log( "这是C" );
        } else {
            console.log( "超神" );
        }

    </script>
</body>
</html>

解决方案

原始的代码有两处错误,一是console语句被注释了,二是type="text/javescript"这句中的javascript拼错了。

这篇关于javascript - js条件语句console.log 不出结果。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆