jquery operation JS Array and object sample code _jquery

Source: Internet
Author: User

Paste a section of jquery on the JS object and array operation: Delete and change the code to check.

Copy Code code as follows:

var worklist = new Array ();//Array Object
The following are the entities that you define
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
+ ", Appointment time:" + Getjsdate (val. BeginTime) + "to" + Getjsdate (val. Endtime) + "<a href=\" #\ "onclick= ' Deletework (\" "+ val.) Id + "\") ' >x</a></span> ';
});
$ ("#tdWorkList"). HTML (HTML);
}
function Addwork () {
if (Checkisnull ("workaddress", "Work address cannot be blank")
&& checkisnull ("Worklevel", "Duty cannot be blank")
&& checkisnull ("Workbegin", "work start date cannot be empty")
&& checkisnull ("Workleave", "work end date cannot be blank")
)
{
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 ("has the same working experience. "); isok= false;
}
});
if (isOK) {
var onework = new Workex ($ ("#workaddress"). Val (), $ ("#worklevel"). Val (),
$ ("#WorkBegin"). Val (), $ ("#WorkLeave"). Val ())
Worklist.push (onework);
<span class= "Add_work_unit" > Lotte District, Sichuan Province, xxx pharmaceutical factory <a href= "#" >x</a></span>
Showwork ();
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.