如何通过使用document.getElementById("id")来更改文本值或选择下拉列表值

34 浏览
0 Comments

如何通过使用document.getElementById("id")来更改文本值或选择下拉列表值

这个问题已经有了答案

使用AngularJS的ng-options处理select

如何使用document.getElementById(\"id\")选择带有给定值的选项:

document.getElementById("dropdownlist").selectedValue="apple";

或者在JavaScript代码中使用它来更改控件的文本。

我是这样填充下拉框的:


admin 更改状态以发布 2023年5月22日
0
0 Comments

尝试这个

    var element = document.getElementById("dropdownlist");
    element.value = "apple";

0
0 Comments

selectedValue 改为 value

document.getElementById("dropdownlist").value = "apple";

0