欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Jquery操作js數(shù)組及對(duì)象示例代碼

 更新時(shí)間:2014年05月11日 22:51:13   作者:  
這篇文章主要介紹了Jquery操作js數(shù)組及對(duì)象示例代碼,需要的朋友可以參考下

貼一段jQuery對(duì)js對(duì)象及數(shù)組的操作:增刪改查的代碼。

復(fù)制代碼 代碼如下:

var WorkList = new Array();//數(shù)組對(duì)象
//下面是自己定義的實(shí)體
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 DeleteWork(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
            + ",任職時(shí)間:" + GetJsDate(val.BeginTime) + "到" + GetJsDate(val.EndTime) + "<a href=\"#\" onclick='DeleteWork(\"" + val.Id + "\")'>×</a></span>";
    });
    $("#tdWorkList").html(html);
}
function AddWork() {
    if(CheckIsNull("workaddress","工作地址不能為空")
        && CheckIsNull("worklevel", "職責(zé)不能為空")
        && CheckIsNull("WorkBegin", "工作開始日期不能為空")
        && CheckIsNull("WorkLeave", "工作結(jié)束日期不能為空")
        )
    {
        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("存在相同的工作經(jīng)歷。"); isok= false;
            } 
        });
        if (isok){
                var onework = new WorkEx($("#workaddress").val(), $("#worklevel").val(),
                        $("#WorkBegin").val(), $("#WorkLeave").val())
                WorkList.push(onework);
                //  <span class="add_work_unit">四川省樂天區(qū)某某制藥廠<a href="#">×</a></span>
                ShowWork();
        }
    }
}

相關(guān)文章

最新評(píng)論