All right, say I have this:
(好吧,说我有这个:)
<select id='list'>
<option value='1'>Option A</option>
<option value='2'>Option B</option>
<option value='3'>Option C</option>
</select>
What would the selector look like if I wanted to get "Option B" when I have the value '2'?
(如果我想获得值“ 2”时选择“选项B”,选择器会是什么样?)
Please note that this is not asking how to get the selected text value, but just any one of them, whether selected or not, depending on the value attribute.
(请注意,这不是在询问如何获取选定的文本值,而是询问其中的任何一个(取决于是否选中),具体取决于value属性。)
I tried: (我试过了:)
$("#list[value='2']").text();
But it is not working.
(但这是行不通的。)
ask by Paolo Bergantino translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…