How can I check whether a option already exist in select by JQuery?
I want to dynamically add options into select and so I need to check whether the option is alread
I had a similar issue. Rather than run the search through the dom every time though the loop for the select control I saved the jquery select element in a variable and did this:
function isValueInSelect($select, data_value){
return $($select).children('option').map(function(index, opt){
return opt.value;
}).get().includes(data_value);
}