使用 jQuery 编辑给定选择值的选项文本的最佳方式是什么。
我知道我要编辑的选项的值。我以为它会像...
$('#select').val().$('option').html('New Text');
但我显然遗漏了一些东西。
最佳答案
$('#select option[value="someValue"]').text("newText")
如果添加 html 内容,可以使用 .html
而不是 .text
。
关于javascript - 使用 jQuery 设置 <option> 元素的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5380704/