2

I am very new with jQuery what I want to ask is getting dropdown list text from jQuery. My dropdownlist is like that:

<select name="Branch[currency_id]" id="Branch_currency_id">
<option value="">Select Currency</option>
<option value="cu-001">Singapore Dollar</option>
<option value="cu-002">US Dollar</option>
</select>

with jQuery I can get dropdownlist value like that:

$(document).ready(function() {
  $('#Branch_currency_id').val();
}

It can only get the value of dropdownlist like cu-001, cu-002 but I don't wanna get like that what I want to get is Singapore Dollar, US Dollar by using jQuery. Can I get like that if so how can I get? Anyone please help me! Thanks! :)

Thyu
  • 109
  • 2
  • 11
  • possible duplicate of [jQuery get specific option tag text](http://stackoverflow.com/questions/196684/jquery-get-specific-option-tag-text) – Praveen Nov 07 '13 at 09:20

6 Answers6

1

Try this:

console.log($('#Branch_currency_id option:selected').text());
codingrose
  • 15,563
  • 11
  • 39
  • 58
1

Try like

$(document).ready(function() {
    var sel_txt = $('#Branch_currency_id option:selected').text();
    alert(sel_txt);
});

See the FIDDLE

GautamD31
  • 28,552
  • 10
  • 64
  • 85
1

Simple approach

$('#Branch_currency_id option:selected').text();
Praveen
  • 55,303
  • 33
  • 133
  • 164
1

Try

alert($("#Branch_currency_id option:selected").text());
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
1

Try this

$("#Branch_currency_id option:selected").html();

OR

$("#Branch_currency_id option:selected").text();
Sridhar R
  • 20,190
  • 6
  • 38
  • 35
1

Try this

alert($('#Branch_currency_id').find('option:selected').text());

or

alert($('#Branch_currency_id option:selected').text());
Prateek
  • 6,785
  • 2
  • 24
  • 37