设置< option>的文本使用jQuery的元素 [英] Setting the text of an <option> element using jQuery
本文介绍了设置< option>的文本使用jQuery的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用jQuery,为给定选择值编辑选项文本的最佳方法是什么.
Using jQuery what is the best way of editing option text for a given select value.
我知道我要编辑的选项的值.我以为那会是...
I know the value of the option I want to edit. I thought it would be something like...
$('#select').val().$('option').html('New Text');
但我显然缺少一些东西.
But I am clearly missing something.
推荐答案
$('#select option[value="someValue"]').text("newText")
如果添加html内容,
可以使用.html
代替.text
.
could use .html
instead of .text
, if adding html content.
这篇关于设置< option>的文本使用jQuery的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文