Javascript jquery";。附加“;选择框中的问题
我在Javascript jquery";。附加“;选择框中的问题,javascript,jquery,append,Javascript,Jquery,Append,我在html中有一个选择选项框 <select name="selectDay" id="selectDay" data-mini="true" style="float: left;"></select> 不要询问dateArrayvar 提前谢谢 试试看: $("#selectDay"). .append($("<option></option>") .attr("value",key)
html
中有一个选择选项框
<select name="selectDay" id="selectDay" data-mini="true" style="float: left;"></select>
不要询问dateArray
var
提前谢谢 试试看:
$("#selectDay").
.append($("<option></option>")
.attr("value",key)
.text(value));
$(“#选择日期”)。
.append($(“”)
.attr(“值”,键)
.文本(值));
试试看
请尝试以下代码:
<select name="selectDay" id="selectDay" data-mini="true" style="float: left;"></select>
<input type="button" id="btnClick" />
最后:)
for(i=0;i
非常感谢您的回答
$("#sendungen select[name='selectDay']").selectmenu("refresh", true); // force rebuild
<select name="selectDay" id="selectDay" data-mini="true" style="float: left;"></select>
<input type="button" id="btnClick" />
$(document).ready(function(){
$("#btnClick").click(function(){
$("#selectDay").append(new Option("option text", "value"));
});
});
for (i = 0; i < dateArray.length; i ++ ) {
var month = dateArray[i].getMonth() + 1;
if (month == 13) month = 1;
var year = dateArray[i].getYear();
year += 1900;
if (i == 0) {
$("#" + site + " select[name='selectDay']").append("<option value=\"" + dateArray[i].getDate() + "-" + month + "-" + year + "\" " + (actuallyDate == dateArray[i] ? "selected='true'" : "") + ">" + showbroadcastsDropDown_localize.today + "</option>");
} else if (i == 1) {
$("#" + site + " select[name='selectDay']").append("<option value=\"" + dateArray[i].getDate() + "-" + month + "-" + year + "\" " + (actuallyDate == dateArray[i] ? "selected='true'" : "") + ">" + showbroadcastsDropDown_localize.tomorrow + "</option>");
} else {
$("#" + site + " select[name='selectDay']").append("<option value=\"" + dateArray[i].getDate() + "-" + month + "-" + year + "\" " + (actuallyDate == dateArray[i] ? "selected='true'" : "") + ">" + dateArray[i].getDate() + "-" + month + "</option>");
}
}
$("#" + site + " select[name='selectDay']").selectmenu("refresh");