Home Web Front-end JS Tutorial Detailed explanation of the steps for Jquery to operate js arrays and objects

Detailed explanation of the steps for Jquery to operate js arrays and objects

Apr 24, 2018 pm 02:38 PM
javascript jquery step

This time I will bring you a detailed explanation of the steps for Jquery to operate jsarraysandobjects. What are the precautions for Jquery to operate js arrays and objects? The following are Let’s take a look at practical cases.

Post a piece of jQuery's operation on js objects and arrays: add, delete, modify and check the code.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

var WorkList = new Array();//数组对象

//下面是自己定义的实体

function WorkEx(depart, title, begintime, endtime) {

    this.SId = 0;

    this.Id = -(WorkList.length+1);

    this.DepartmentName = depart;

    this.Title = title;

    this.BeginTime = begintime;

    this.EndTime = endtime;

    this.Description = "";

    this.Enable = 0;

    return this;

}

function

Delete

Work(guid) {

      WorkList = $.grep(WorkList, function (val, key) {

          return val.Id != guid;

    });

      ShowWork();

}

function ShowWork() {

    var html = "";

    $.each(WorkList, function (key, val) {

        html = html + " <span class=\"add_work_unit\">" + val.DepartmentName + ":" + val.Title

            + ",任职时间:" + GetJsDate(val.BeginTime) + "到" + GetJsDate(val.EndTime) + "<a href=\"#\"

onclick

='DeleteWork(\"" + val.Id + "\")'>×</a></span>";

    });

    $("#tdWorkList").html(html);

}

function AddWork() {

    if(CheckIsNull("workaddress","工作地址不能为空")

        && CheckIsNull("worklevel", "职责不能为空")

        && CheckIsNull("WorkBegin", "工作开始日期不能为空")

        && CheckIsNull("WorkLeave", "工作结束日期不能为空")

        )

    {

        var isok = true;

        $.each(WorkList, function (key, val) {

            if (val.DepartmentName == $("#workaddress").val()

              && val.Title == $("#worklevel").val()

                && val.BeginTime == $("#WorkBegin").val()

                 && val.EndTime == $("#WorkLeave").val()

                )

            {

                alert("存在相同的工作经历。"); isok= false;

            

        });

        if (isok){

                var onework = new WorkEx($("#workaddress").val(), $("#worklevel").val(),

                        $("#WorkBegin").val(), $("#WorkLeave").val())

                WorkList.push(onework);

                //  <span class="add_work_unit">四川省乐天区某某制药厂<a href="#">×</a></span>

                ShowWork();

        }

    }

}

Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

jQuery plug-in implements table color change on alternate rows and interacts with mouse events

jquery moves from array Detailed explanation of steps to remove selected values

The above is the detailed content of Detailed explanation of the steps for Jquery to operate js arrays and objects. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

How to make Google Maps the default map in iPhone

This Apple ID is not yet in use in the iTunes Store: Fix This Apple ID is not yet in use in the iTunes Store: Fix Jun 10, 2024 pm 05:42 PM

This Apple ID is not yet in use in the iTunes Store: Fix

Steps to upgrade to the latest version of WeChat (Easily master the upgrade method to the latest version of WeChat) Steps to upgrade to the latest version of WeChat (Easily master the upgrade method to the latest version of WeChat) Jun 01, 2024 pm 10:24 PM

Steps to upgrade to the latest version of WeChat (Easily master the upgrade method to the latest version of WeChat)

Detailed explanation of the steps to obtain Win11 system administrator permissions Detailed explanation of the steps to obtain Win11 system administrator permissions Mar 08, 2024 pm 09:09 PM

Detailed explanation of the steps to obtain Win11 system administrator permissions

Safari zoom issue on iPhone: Here's the fix Safari zoom issue on iPhone: Here's the fix Apr 20, 2024 am 08:08 AM

Safari zoom issue on iPhone: Here's the fix

Shazam app not working in iPhone: Fix Shazam app not working in iPhone: Fix Jun 08, 2024 pm 12:36 PM

Shazam app not working in iPhone: Fix

iPhone screenshots not working: How to fix it iPhone screenshots not working: How to fix it May 03, 2024 pm 09:16 PM

iPhone screenshots not working: How to fix it

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Clock app missing in iPhone: How to fix it

See all articles