有一些类型的插件来做到这一点?该服务器将返回JSON内容包含选项标签和值。
Is there some type of plugin to do this? The server will return JSON content containing the option labels and values.
我可以手动做到这一点,我只是想看看是否有更简单的方法。
I can do this manually, I just wanted to see if there was an easier way.
循环通过JSON和做每个文/值对(工程跨浏览器很好):
Loop through the json and do this on each text/value pair (works cross-browser nicely):
var opt = document.createElement('option');
opt.value = "someValue";
opt.appendChild(document.createTextNode("someText"));
$('#mySelect').append(opt);