I need to get selected value from select field using jquery in magento
<field name="slider_location">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="component" xsi:type="string">Vendor_Modulename/js/form/element/containers</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="label" xsi:type="string" translate="true">Display On</item>
 <item name="formElement" xsi:type="string">select</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataScope" xsi:type="string">slider_location</item>
 </item>
 </argument>
 </field>
1 Answer 1
You can simply get it with the select name attribute 
$('select[name=general[slider_location]]').val();
Note: general → is the fieldset name, change it accordingly. 
You can bind the it on change event: 
$(document).ready(function(){
 $('select[name="slider_details[slider_location]"]').change(function(){
 alert( this.value );
 });
});
 answered Jun 10, 2019 at 9:53
 
 
 
 fmsthird 
 
 4,6224 gold badges18 silver badges42 bronze badges
 
 - 
 i addedjQuery('select[name=slider_details[slider_location]]').val();got a console errorsyntax error, unrecognized expression: select[name=slider_details[slider_location]]Waqar Ali– Waqar Ali2019年06月10日 09:57:19 +00:00Commented Jun 10, 2019 at 9:57
- 
 try like$('select[name="slider_details[slider_location]"]').val();fmsthird– fmsthird2019年06月10日 10:05:36 +00:00Commented Jun 10, 2019 at 10:05
- 
 i want to get value in initalize function there it is not working otherwise its working wellWaqar Ali– Waqar Ali2019年06月10日 11:04:44 +00:00Commented Jun 10, 2019 at 11:04
- 
 can you check updated answerfmsthird– fmsthird2019年06月10日 11:35:56 +00:00Commented Jun 10, 2019 at 11:35
default
 
 
 
<item name="formElement" xsi:type="string">select</item>