Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get the Selected value for the select choice element

I have tried to get the value of the selected option as,var

doma=$('#domain_picker_select').find('option:selected').text();
OR
var doma=$('#domain_picker_select').val(); 

but i am getting the output as undefined, please help me to get the values for the option been selected for the select choice.

<select name="domain_picker_select"ng-options="domain.value as domain.label for domain in domains.list" id="domain_picker_select">
<option label="global" value="string:global" selected="selected">global</option>
<option label="TOP/Comm" value="string:6b16be7e6f72710f6">TOP/GBP/Comm</option>
<option label="TOP/Custom" value="string:e15e65256f9bd23">TOP/Custom</option>
</select>
like image 640
Rishi Reddy Avatar asked Feb 04 '26 11:02

Rishi Reddy


1 Answers

To get value, you use val()

$("#domain_picker_select").val();

It work good! https://codepen.io/anon/pen/ZBNxPo

like image 91
nartoan Avatar answered Feb 06 '26 00:02

nartoan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!