
需要點一下,樣式才會變成下面的

$(function () {
var selectData = null;
$('#id_select2_demo1').click();
$('#id_select2_demo1').click(function () {
if (selectData == null) {
$.ajax({
type: "post", //要用post方式
async: false,
url: "LEOHBHUBPLANT001.aspx/GetHubCode", //方法所在頁面和方法名
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
selectData = data.d; //回傳的資料用data.d獲取內容
},
error: function (err) {
alert(err);
}
});
}
$('#id_select2_demo1').select2({
placeholder: '請選擇',
allowClear: true,
data: selectData,
cache: true
});
})
});
uj5u.com熱心網友回復:
在onload方法中或者$(function()){}中給select設定下樣式 或者默認html中先設定下樣式轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/284647.html
標籤:JavaScript
