Home >Web Front-end >HTML Tutorial >3 different ways to clear the option option in the select tag_html/css_WEB-ITnose

3 different ways to clear the option option in the select tag_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:53:461123browse

This article introduces in detail three different ways to clear the options in the select tag. The specific syntax format is as follows. Interested friends can refer to it. I hope it will be helpful to everyone

Method 1

Copy code

The code is as follows:


document.getElementById("selectid").options.length = 0;


Method 2

Copy code

The code is as follows:


document.formName.selectName.options.length = 0;


Method 3

Copy code

The code is as follows:


document.getElementById("selectid").innerHTML = "";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn