我試圖將從表單元素捕獲的變量拉入到函數鏈中。變量值需要充當函數名稱。例如:JavaScript變量鏈中的函數名稱
<form name="myform">
<input type="radio" id="DayOfWeek" name="DayOfWeek" value="monday" />Monday
<input type="radio" id="DayOfWeek" name="DayOfWeek" value="tuesday" />Tuesday
<input type="radio" id="DayOfWeek" name="DayOfWeek" value="wednesday" />Wednesday
<input type="radio" id="DayOfWeek" name="DayOfWeek" value="thursday" />Thursday
<input type="radio" id="DayOfWeek" name="DayOfWeek" value="friday" />Friday
</form>
腳本:
var **monthday**=$("input[name='DayOfWeek']:checked").val();
NewDate = Date.parse(NewDate).add(1).month().**monthday**();
我的問題已經越來越變量「MONTHDAY」值作爲該鏈中的函數名。我有一個'唔'的時刻,或者這是不可能的?
還記得,在JS對象是 「字典」,一切都是對象 – Guillaume86