方法一

代码如下:
document.getElementById("selectid").options.length = 0;

方法二

代码如下:
document.formName.selectName.options.length = 0;

方法三

代码如下:
document.getElementById("selectid").innerHTML = "";

其他方法:
var nian = document.getElementById("nian");
var length = nian.options.length;

for(var i=0; i < length; ){
//nian.options.remove(i);
//length=length/2;
}

清空select标签中option选项的3种不同方式的更多相关文章

  1. 清空select标签中option选项的4种不同方式

    转自:https://blog.csdn.net/pt_sm/article/details/53521560 方法一 document.getElementById("selectid&q ...

  2. select标签中的选项分组

    select标签中的选项分组 <select name="showtimes"> <optgroup label="下午一点"> < ...

  3. select标签中option内容加链接

    1.Html页面代码 <select name="select" id="select" style="height: 25px; width: ...

  4. vue-learning:41 - Vuex - 第二篇:const store = new Vue.Store(option)中option选项、store实例对象的属性和方法

    vuex 第二篇:const store = new Vue.Store(option)中option选项.store实例对象的属性和方法 import Vuex from 'vuex' const ...

  5. <select>标签,不要在select标签中写value属性!!!

    <select> select标签,一个选择框标签,在开发中很多时候会用到这个标签,例如选择生日19**年,或者在segmentfault中编辑文章时选择'原创','转载',还是'翻译'等 ...

  6. C#中char空值的几种表示方式

    C#中char空值的几种表示方式 在C#中char类型的表示方式通常是用单引号作为分隔符,而字符串是用双引号作为分隔符. 例如: 程序代码 程序代码 char a = 'a'; char b = 'b ...

  7. 解决Select标签的Option在IE浏览中display:none不生效的问题

    页面的Select标签,需要控制Select的Option不需要显示,根据条件来隐藏某些Option选项. 正常情况下使用hide()就能实现,hide()方法实际是给Option加上display属 ...

  8. 用jquery获取select标签中选中的option值及文本

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  9. 利用js给datalist或select动态添加option选项

    <!DOCTYPE html> <html> <head> <title>鼠标点击时加载</title> <script type=& ...

随机推荐

  1. MySQL 错误 1366:1366 Incorrect integer value

    错误提示:General error: 1366 Incorrect integer value: '' for column 'pay_type' at row 1 (SQL: INSERT INT ...

  2. Excel VBA 教程

    https://www.w3cschool.cn/excelvba/  Excel VBA 编程教程 https://www.yiibai.com/vba   VBA教程 http://www.acc ...

  3. A - ACM Rank Table

    ACM contests, like the one you are participating in, are hosted by the special software. That softwa ...

  4. js 使用a标签 下载资源

    文档 let data = new Blob(['hello ajanuw'], { type: 'application/text' }) let src = window.URL.createOb ...

  5. 网络通信协议五之IP协议详解

    网络层协议 >>IP协议 >>ARP(地址解析协议) >>RARP(反向地址解析协议) >>ICMP(互联网控制消息协议) IP协议功能 >> ...

  6. Python不支持函数重载

    函数重载与Python: 函数重载的好处就是不用为了不同的参数类型或参数个数,而写多个函数.多个函数用同一个名字,但参数表,即参数的个数和数据类型可以不同.调用的时候,虽然方法名字相同,但根据参数表可 ...

  7. C#5种方式生成缩略图

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  8. Nodejs----基本数据类型

    Nodejs基本数据类型: nodejs的基础JavaScript(脚本语言). 而大多数的

  9. http://linux-mtd.infradead.org/doc/nand.html nand

    http://linux-mtd.infradead.org/doc/nand.html

  10. 汇编debug工具详解

    关于debug工具里的各个指令的用法 debug调试工具详解: r:可以查看,和改变寄存器中的内容具体用法:·直接输入r的时候,回车显示当前指向内存单元中所有寄存器中的内容,并将所指机器码翻译成汇编指 ...