如何获取选择标签中的列表项?我尝试了很多不同的方法,但没有任何效果。 我的代码:
<select id ="listBox" multiple="multiple" style="width:200px; height:400px;">
<option></option>
</select>
function onSuccess1() {
var lstBox= document.getElementById('listBox');
lstBox.options.length = 0;
var listEnumerator = listItems.getEnumerator();
while (listEnumerator.moveNext()) {
var currentItem = listEnumerator.get_current();
var listBoxItems = currentItem.get_item("Title");
lstBox.options[lstBox.options.length] = new Option(listBoxItems, currentItem.get_item("Title"));
}
最佳答案
老实说,我不明白你的代码,所以这里就像一般情况下一样:
function add()
{
var select = document.getElementById ("my_select");
var o = document.createElement("option");
o.text = "New Option";
select.add (o);
}
Click the button to add an option to the select list.
<br>
<select id="my_select">
</select>
<input type="submit" onclick="add();" value="Add another option" />
关于javascript - 获取选择标签中的列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32629692/