如何从选择框中删除选定的属性

How to remove selected attribute from select box?

本文关键字:属性 删除 选择      更新时间:2023-09-26

我有一个包含一些值的选择框。单击按钮后,我想删除任何具有此属性的选项值的选定属性。基本上我想重新加载选择框。我不使用jquery,所以在纯javscript中有什么方法可以完成它吗?

我在另一篇帖子中问过它,因为所有与该帖子相关的答案都在Jquery中,我只想用javascript来做。

我使用removeAttribute函数作为

document.getElementById('selectboxID').removeAttribute("selected")

但它不起作用。

根据:http://www.w3schools.com/jsref/prop_select_selectedindex.asp

document.getElementById("selectboxID").selectedIndex = -1;

应该做的技巧