之前:
![mark](http://qiniu.newthink.cc/blog/20171211-085752325.png)
之后:
![mark](http://qiniu.newthink.cc/blog/20171211-085814462.png)
## 关键代码
```
$("select option").each(function() {
text = $(this).text();
if($("select option:contains("+text+")").length > 1)
$("select option:contains("+text+"):gt(0)").remove();
});
```
## 示例代码
例:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script>
</head>
<body>
<h2>去掉select重复的option值</h2>
<select id="test">
<option value="1">1</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<script>
$(function () {
$("select option").each(function() {
text = $(this).text();
if($("select option:contains("+text+")").length > 1)
$("select option:contains("+text+"):gt(0)").remove();
});
console.log(text);
})
</script>
</body>
</html>
```