我在jquery中有一个变量。首先我要添加一些值。 现在再次向现有变量添加更多值。 这是我的代码。如果有人知道帮助我......
var eventToAdd = {
title: $("#txtSubject").val(),
description: $("#addEventDesc").val(),
start: $("#txtStartdate").val(),
end: $("#txtEnddate").val()
};
var ChkBox = document.getElementById("rbtnHourly");
if (ChkBox.checked == true) {
**eventToAdd = {**
FREQ: "Hourly",
INTERVAL: $("#updown").val(),
BYSETPOS: "",
BYDAY: "",
BYMONTH: "",
BYMONTHDAY: ""
};
}
var ChkBox = document.getElementById("rbtnDaily");
if (ChkBox.checked == true) {
var rbtnEveryday = document.getElementById("rbtnEveryday");
if (rbtnEveryday.checked == true) {
**eventToAdd = {**
FREQ: "Daily",
INTERVAL: $("#TextBox1").val(),
BYSETPOS: "",
BYDAY: "MO,TU,WE,TH,FR,SA,SU",
BYMONTH: "",
BYMONTHDAY: ""
};
}
else {
**var eventToAdd1 = {**
FREQ: "Daily",
INTERVAL: 1,
BYSETPOS: "",
BYDAY: "MO,TU,WE,TH,FR",
BYMONTH: "",
BYMONTHDAY: ""
};
};
}
答案 0 :(得分:0)
答案 1 :(得分:0)
通过为其分配属性,可以向现有对象添加值:
if (ChkBox.checked) {
eventToAdd.FREQ = "Hourly";
eventToAdd.INTERVAL = $("#updown").val();
eventToAdd.BYSETPOS = "";
eventToAdd.BYDAY = "";
eventToAdd.BYMONTH = "";
eventToAdd.BYMONTHDAY = "";
}