当我选择一个选项时,我有一个带有所需选项的选择
<select class="select cf-select" name="customfield_10303" id="customfield_10303">
<option value="">None</option>
<option value="10200">Opened</option>
<option value="10201">Closed</option>
<option value="10202">Escalated</option>
<option value="10203">Handled</option>
<option value="10204">Deferred</option>
<option value="10205">Reopened</option>
<option value="10206">Could Not Be Resolved</option>
</select>
这是HTML代码,当我选择打开时,只需要javascript代码即可
答案 0 :(得分:0)
您到底有多需要他们disappear
?在这里,我只是从DOM中删除它们。
const selector = document.querySelector("select");
selector.addEventListener("click", addActivityItem);
function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}
<select>
<option>One</option>
<option>Two</option>
</select>