Bootstrap dropdown checkbox select

前端 未结 3 430
醉酒成梦
醉酒成梦 2020-12-14 02:05

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 \

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 02:45

    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);
            });
        });
    });
    

提交回复
热议问题