Blogger Information
Blog 30
fans 1
comment 0
visits 24258
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS数组函数和常见事件 20191022
阿乎乎的学习
Original
833 people have browsed it

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>JS基础</title>
</head>
<body>
    <div style="width: 300px;height: 200px;background-color: greenyellow" onmouseover="over()" onmouseleave="leave()" onclick="click()"></div>
    <div style="width: 300px;height: 200px;background-color: yellow;display:none;" id="div"></div>
    <input type="email" placeholder="邮箱" onblur="check()">
    <input type="phone" placeholder="手机">

    <select name="" id="" onchange="change()">
        <option value="">重庆</option>
        <option value="">上海</option>
    </select>
    <script>
        var num=[1,2,3,4,5,6,7,8,9];
        console.log(num);
        //数组最后添加元素
        num.push(10);
        console.log(num);
        //在数组最前添加元素
        num.unshift(0);
        console.log(num);
        //删除数组最后一个元素,事实上是取出最后一个元素
        var num1=num.pop();
        console.log(num);
        console.log('取出的最后一个元素是'+num1);
        //删除数组第一个元素,事实上是取出第一个元素
        var num2=num.shift();
        console.log(num);
        console.log('取出的第一个元素是'+num2);
        //删除指定元素
        num.splice(1,2); //删除从下标1开始的两个元素
        console.log(num);
        //js基本动画演示
        function over(){
            console.log('鼠标移入了');
        }
        function leave(){
            console.log('鼠标离开了')
        }
        //检查文本提示
        function check(){
            alert('邮箱不合法');
        }
        function change(){
            alert('值变了');
        }
        //打开网页就跳转到另一个网页
        // window.location.href="http://www.baidu.com"
    </script>
</body>
</html>

运行实例 »

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

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