美文网首页
bootstrap selectpicker

bootstrap selectpicker

作者: shaguamayi | 来源:发表于2019-03-07 10:58 被阅读0次
    $.ajax({
                    type: 'get',
                    url: systemConfig.backendurl + '/api/fl/gettype?type=1',
                    async: false,
                    success: function(res) {
                        if (res.success) {
                            var select = $("#selectwrap");
                            var datas = res.data;
                            for (var i = 0; i < datas.length; i++) {
                                select.append("<option value='" + datas[i].code + "'>" +
                                    datas[i].name + "</option>");
                            }
                            $('.selectpicker').selectpicker('val', ['07', '06', '08']);//设置回显值
                            $('.selectpicker').selectpicker('refresh');
                            $('.selectpicker').selectpicker('render');
                            console.log($('.selectpicker').selectpicker('val'));//打印选择的值
                        }
                    },
                    error: function(err) {
                        console.log(err)
                    }
                })
    
                $('.selectpicker').on('changed.bs.select', function() {//单击时方法
                    console.log('agja');
                    var val = $(this).val();
                    console.log($('.selectpicker').selectpicker('val'));
                });
    
    //html要引入bootstrap.min.js bootstrap-select.min.js bootstrap-select.min.css"
    <select class="selectpicker" data-live-search="true" multiple id='selectwrap'></select>
    

    相关文章

      网友评论

          本文标题:bootstrap selectpicker

          本文链接:https://www.haomeiwen.com/subject/oeoqpqtx.html