Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

select2 find option by text

let long_name = 'Australia';
let $element = $('.country-js')
let val = $element.find("option:contains('"+long_name+"')").val()
$element.val(val).trigger('change.select2');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #option #text
ADD COMMENT
Topic
Name
3+3 =