Blogger Information
Blog 40
fans 0
comment 0
visits 37496
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS学习总结(1)基础实例——2019年10月21号20:00分
虎子爸爸
Original
699 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>JavaScript基础知识</title>
</head>

<body>
    <h3>JS变量,语句,表达式</h3>
    输入名字:<input type="text" name="name" id="input-a" onblur="log(this.value)">
    <p id="js-p-a" style="color:red;font-weight:500;"></p>

</body>

</html>
<script>
    //定义一个变量
    var username = "xiaohu";
    //定义一个命名函数
    function reg() {
        alert('hao');
    }
    //定义一个函数
    function log($name) {
    //一个简单if语句
        if ($name == username) {
            alert("登录成功");
            document.getElementById("js-p-a").innerHTML = "欢迎你回来:" + $name;
        } else {
            alert("账户或密码错误");
            document.getElementById("input-a").value = '';
            document.getElementById("js-p-a").innerHTML = "账户或密码错误,请重新输入";
        }
    }
    //一个匿名函数
    window.onload = function() {
        alert("别乱动");
    };
    //调用一个函数
    window.onload = reg();
</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:不错
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post