我有2個碼,ASP.NET DROPDOWNLIST到jQuery的variabel
這是第一條:
$("#Button1")
.click(function() {
var index;
var select = $("#DropDownList1");
var select = document.getElementById("DropDownList1");
var myindex = ["zero", "one", "two", "three"];
for (index = 0; index < myindex.length; index++) {
select.appendChild(new Option(myindex[index]));
}
});
這是第二個:
$("#Button1")
.click(function() {
var index;
var select = document.getElementById("DropDownList1");
var myindex = ["zero", "one", "two", "three"];
for (index = 0; index < myindex.length; index++) {
select.appendChild(new Option(myindex[index]));
}
});
爲什麼第一個代碼不工作?
var select = $("#DropDownList1");
我必須將它更改爲
var select = document.getElementById("DropDownList1");
我想打開$( 「#DropDownList1」)到variabel。
這是工作。謝謝你 –