Reputation: 109
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! :)
Upvotes: 2
Views: 79
Reputation: 6965
Try this
alert($('#Branch_currency_id').find('option:selected').text());
or
alert($('#Branch_currency_id option:selected').text());
Upvotes: 1
Reputation: 28763
Try like
$(document).ready(function() {
var sel_txt = $('#Branch_currency_id option:selected').text();
alert(sel_txt);
});
See the FIDDLE
Upvotes: 1
Reputation: 20408
Try this
$("#Branch_currency_id option:selected").html();
OR
$("#Branch_currency_id option:selected").text();
Upvotes: 1
Reputation: 57105
Try
alert($("#Branch_currency_id option:selected").text());
Upvotes: 1
Reputation: 15699
Try this:
console.log($('#Branch_currency_id option:selected').text());
Upvotes: 1