[英]Bootstrap select: selecting options using jquery
I'm trying to select the already selected options via jquery, however the black tick
isn't visible: 我正在尝试通过jquery选择已经选择的选项,但是黑色tick
不可见:
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: 还尝试了click
,在外壳上显示它已被选中,但在站点示例中未显示选择:
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, 我对bootstrap-select的了解不多,但是在深入研究之后,我找到了一种方法,
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, 假设select标签具有#selecting ID,
now call this to refresh bootstrap-select to get that tick, 现在调用它来刷新引导程序选择以获取刻度,
$("#selecting").data("selectpicker").refresh()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.