---
title: "jquery获得select option的值 和对select option的操作"
author: "java4evero"
date: "2011-12-21T16:34:01Z"
tags: []
slug: "jquery-select-option-select-option"
draft: false
lastmod: "2011-12-21T16:34:01Z"
id: 1319692
url: "https://java4evero.iteye.com/blog/1319692"
---

获取Select ：
 获取select 选中的 text :

```js
   $("#ddlRegType").find("option:selected").text();
```

 获取select选中的 value:
 
```js
  $("#ddlRegType ").val();
```

 获取select选中的索引:
 
```js
    $("#ddlRegType ").get(0).selectedIndex;
```

设置select:
 设置select 选中的索引：

```js
     $("#ddlRegType ").get(0).selectedIndex=index;//index为索引值

```

 设置select 选中的value：

```js
    $("#ddlRegType ").attr("value","Normal“);
    $("#ddlRegType ").val("Normal");
    $("#ddlRegType ").get(0).value = value;
```

 
 设置select 选中的text:

```js

var count=$("#ddlRegType option").length;
  for(var i=0;i<count;i++)  
     {           if($("#ddlRegType ").get(0).options[i].text == text)  
        {  
            $("#ddlRegType ").get(0).options[i].selected = true;  
          
            break;  
        }  
    }
$("#select_id option[text='jQuery']").attr("selected", true);
```