Jquery操作js配列およびオブジェクトサンプルコード
2709 ワード
jQueryのjsオブジェクトと配列に対する操作:削除して調べるコードを貼ります.
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 DeleteWork(guid) {
WorkList = $.grep(WorkList, function (val, key) {
return val.Id != guid;
});
ShowWork();
}
function ShowWork() {
var html = "";
$.each(WorkList, function (key, val) {
html = html + " " + val.DepartmentName + ":" + val.Title
+ ", :" + GetJsDate(val.BeginTime) + " " + GetJsDate(val.EndTime) + "×";
});
$("#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);
// ×
ShowWork();
}
}
}