Blogger Information
Blog 23
fans 0
comment 0
visits 13685
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
20191023作业
王长中的博客
Original
697 people have browsed it

1,通过JS创建对象,属性,方法

实例

  var person = new Object();    //创建对象;
    person.name = "lisi";       //创建属性;
    person.age = 21;
    person.family = ["lida", "lier", "wangwu"];
    person.say = function () {                //创建方法;
     return this.name;
    };
    console.log (person.say());      //返回 lisi;
    console.log (person.family[2]);  // 返回wangwu;

运行实例 »

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

2.Jquery选择器的使用和$each循环

实例

<!DOCTYPE html>
<html>
<head>
    <title>jquery</title>
    <script src="../jquery-3.4.1.min.js"></script>
</head>
<body>
<div class="main">
    <div class="header">
        <div class="nav">
            <a id="home">首页</a>
            <a>视频教程</a>
        </div>
    </div>

    <div class="imgs">
        <img src="">
    </div>
</div>
</body>
<script>
    var num = $('#home').html();
    console.log(num);
    var res = $('.main>div');
    console.log(res.length);
    $.each(res, function (i, v) {
        console.log(v);
    });


    </script>
</html>

运行实例 »

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


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