返回

jquery.combo.select插件设置选中项

2019-08-06 jquery.combo.select 4132 0

jquery.combo.select插件使用很简单,默认使用方法是:

$(function() {
    $('select').comboSelect();
});

这样就能模拟一个漂亮的下拉菜单。

如何用js修改或者设置jquery.combo.select的默认选中项呢?

例如我现在想把value=0的那个项选中,那么设置方法如下:

$("select option[value='0']").prop("selected", "selected");//将select的value=0的项选中
$("select").comboSelect().trigger('change.select');//触发更新jquery.combo.select

只是修改select的选中项是不够的,再执行trigger('change.select')就能更新下拉菜单了。

顶部