i need to get selected option value in JqueryUI SelectMenu out of change event, But i can't get value out of Change function or selectmenu function, how to do it/
var iSelectedValue;
var map="";
$("#drpRegionName").selectmenu({
change: function (event, ui) {
iSelectedValue = ui.item.value;
console.log(iSelectedValue); //Working
},
select: function (event, ui) {
map = $(this).val();
console.log(map); //working
}
});
console.log(map); // not working
console.log($(iSelectedValue); // not working
out of the function its undefined.
Consider the following example, based on https://jqueryui.com/selectmenu/#product-selection
You can see here how we can update the Array when the page loads and then anytime a
changeevent happens for one of the selectMenu items.Hope that helps.