Answers for "select2 find option by text"

1

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');
Posted by: Guest on September-17-2021
1

select2 find option by text

$("#select").select2("val", $("#select option:contains('Text')").val() );
Posted by: Guest on September-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language