I'm trying to select the already selected options via jquery, however the black tick
isn't visible:
Tried selecting it:
$('.skills :last').find('option:contains("Calculating data")').prop('selected', true);
[option]
$('.skills :last').val();
["Calculating data↵"]
$('.skills');
[div.btn-group.bootstrap-select.show-tick.skills.job-seeker-content-spacing, select.selectpicker.skills.job-seeker-content-spacing]
$('.skills :first').find('option:contains("Calculating data")').prop('selected', true);
[option]
$('.skills :first').val();
""
also tried with click
, on the shell it shows it's been selected but doesn't show the select on the site example:
If you want the text :
var text = $('.skills').find(":selected").text();
If you want the value :
var value = $('.skills').find(":selected").val();
I don't know much about bootstrap-select but after some digging into it, I fount a way,
after you call
$('.skills :last').find('option:contains("Calculating data")').prop('selected', true);
The option get selected and works properly,
let's assume the select tag has #selecting id,
now call this to refresh bootstrap-select to get that tick,
$("#selecting").data("selectpicker").refresh()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.