开发者

get the text of the option from the value of the combobox [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

jQuery get select option text

let's say that i have the value of the combo but without make a selection开发者_如何学Go, now i want to know how can i make a selector that brings me the text of that value

the html

<select class=".ddlOperators" >
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
      <option value="3">Value 3</option>
      <option value="4">Value 4</option>
 </select>

I tried like this

$(".ddlOperators option").find('1')

notes that 1 was the value of the option of the combo


$(".ddlOperators option[value='1']").text();

Also, your class for the select element should not be preceded by a dot, it should be:

<select class="ddlOperators">

Demo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜