---
title: "option操作小结"
author: "cindysaj"
date: "2008-12-01T17:30:53Z"
tags: []
slug: "option"
draft: false
lastmod: "2008-12-01T17:30:53Z"
id: 284221
url: "https://cindysaj.iteye.com/blog/284221"
---

1在select列表第一行增加一个option的方法
方法1.document.getElementById("sel").add(new Option("1","1"),0);

方法2var y=document.createElement('option');
  y.text='2';
  y.value='2';
  document.getElementById("sel").add(y,0); //0为索引号

2在select列表第一行修改一个option的方法,注意是覆盖
document.getElementById('selectId').options[0] = new Option("1","1");


3在select列表删除一个option的方法  		
document.getElementById("sel").remove(0);//0为索引号
