---
title: "用javascript操作select"
author: "netxdiy"
date: "2007-06-15T09:36:00Z"
tags: []
slug: "javascript-select"
draft: false
lastmod: "2012-09-27T11:21:32Z"
id: 1686732
url: "https://netxdiy.iteye.com/blog/1686732"
---

1 检测是否有选中  
if(objSelect.selectedIndex &gt; -1) {  
//说明选中  
} else {  
//说明没有选中  
}  
2 删除被选中的项  
objSelect.options\[objSelect.selectedIndex] = null;  
3 增加项  
objSelect.options\[objSelect.length] = new Option("你好","hello");  
4 修改所选择中的项  
objSelect.options\[objSelect.selectedIndex] = new Option("你好","hello");  
5 得到所选择项的文本  
objSelect.options\[objSelect.selectedIndex].text;  
6 得到所选择项的值  
objSelect.options\[objSelect.selectedIndex].value;