Bootstrap下拉复选框选择 [英] Bootstrap dropdown checkbox select

查看:916
本文介绍了Bootstrap下拉复选框选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图自定义一个引导下拉框与复选框,如果我从下拉列表中选择一个复选框我想要写在输入下拉列表用';



这是一个 fiddle example



解决方案

不是最优雅的解决方案 - 你可能想改进这一点,但这可能让你开始:

  $(document) .ready(function(){
$(this).change(function(){
var line =;
$(ul.dropdown-菜单输入[type = checkbox])每个(function(){
if($(this).is :checked)){
line + = $(+ span,this).text()+;;
}
});
$(input.form-control)。val(line);
});
});
});


I'm trying to customize a bootstrap dropdown with checkboxes and if I select a checkbox from dropdown the label name I want to be written on input dropdown delimited with ';' like in uploaded picture when dropdown is closed.

Here is a fiddle example.

解决方案

Not the most elegant solution - you will probably want to refine this somewhat, but this might get you started:

$(document).ready(function() {
    $("ul.dropdown-menu input[type=checkbox]").each(function() {
        $(this).change(function() {
            var line = "";
            $("ul.dropdown-menu input[type=checkbox]").each(function() {
                if($(this).is(":checked")) {
                    line += $("+ span", this).text() + ";";
                }
            });
            $("input.form-control").val(line);
        });
    });
});

这篇关于Bootstrap下拉复选框选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆