编辑第一个选项名称 [英] edit the first option name
本文介绍了编辑第一个选项名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,我无法访问。
I have the following code which I do not have access to.
我想要做的是在第一个选项中添加一些文本,现在为空。诸如选择地址之类的文本
What I want to do is add some text into the first option which is now empty. Text such as "Select Address"
<select name="My_Saved_Billing"
onChange="Choose_My_Saved_Billing(this.selectedIndex)" style="background-color:#EEEEEE">
<option></option>
<option value="1394">text</option>
</select>
推荐答案
$('select[name=My_Saved_Billing] > option:first-child')
.text('Select Address');
如果你想找到空的选项,而不只是第一个,请使用:
If you want to find the empty option(s), not just the first one, use:
$('select[name=My_Saved_Billing] > option:empty')
// or
$('select[name=My_Saved_Billing] > option:empty:first')
获取具有特定内容的选项,请使用:
To get the option with specific content, use:
$('select[name=My_Saved_Billing] > option:contains(texthere)')
这篇关于编辑第一个选项名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文