jQuery如何查找和替换具有特定值的选定选项 [英] jquery how to find and replace a selected option that has a certain value

查看:118
本文介绍了jQuery如何查找和替换具有特定值的选定选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以在选中的选项中找到具有特定值的选项并将其替换?

Is there any way to find in a select the selected option that has a certain value and replace it ?

<div id="l1col1" class="selects1" ></div>
<div id="l1col2" class="selects1" ><select><option selected>2</option></select></div>
<div id="l1col3" class="selects1" ><select><option selected>1</option></select></div> 

我会更加清楚,在上面的示例中,我想找到将选项选择为1并将其替换为3的select,这可能吗?

I will be more clear, in the example above i want to find the select that has the option selected as 1 and replace it with 3 , is this possible ?

推荐答案

您可以使用:contains

$('.selects1 :selected:contains("1")').text('3');

演示

这篇关于jQuery如何查找和替换具有特定值的选定选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆