我想使選擇器組件與一些選項。我沒有得到任何結果。我正在做這件事的方式有點不對勁。如何製作選定的元素並追加選項?
任何人都可以幫助我嗎?
var object = {
"id":"countries",
"label":"Country",
"name":"countries",
"type":"select",
"options":[
{
"value":"",
"text":"Select Country"
},
{
"value":"in",
"text":"India",
"selected":"true"
},
{
"value":"us",
"text":"United Stated"
},
{
"value":"uk",
"text":"United Kingdom"
},
{
"value":"cn",
"text":"Canada"
}
]
};
var select = "";
var mapInfo = function (element,info) {
$.map(info, function(val,num){
console.log(val);
})
}
var generateSelector = function (info){
select +='<select'+info.id+'></select>'
select +=mapInfo(select,info.options)
$('body').append(select);
}(object);