Bootstrap下拉复选框选择 [英] Bootstrap dropdown checkbox select
本文介绍了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屋!
查看全文