<div class="col-md-7">
<div class="input-group">
<input type="text" class="form-control" value="不限,中国共产党预备党员" id="selValuepolitical" disabled="" />
<span class="input-group-btn"> <button type="button" class="btn btn-default collapsed" data-toggle="collapse" data-target="#政治面貌" aria-expanded="false" aria-controls="政治面貌"> <span class="caret"></span> </button> </span>
</div>
<label for="political" generated="true" class="error" style="display: none;"></label>
<div class="collapse" id="政治面貌" aria-expanded="false" style="height: 0px;">
<div class="panel panel-default">
<div class="checkbox col-md-offset-1">
<label><input checked="checked" name="political" type="checkbox" value="00" />不限</label>
</div>
<div class="checkbox col-md-offset-1">
<label><input name="political" type="checkbox" value="01" />中国共产党党员</label>
</div>
</div>
</div>
</div>
页面上有多组checkbox 监听点击事件,将所有选择的赋值到文本
<script>
/* 选择后 显示选择的项 */
$(".collapse input[type='checkbox']").on('click',function() {
var checkName = $(this).attr("name");
var selText =[];
$("input:checked[name=" + checkName+"]").each(function(index) {
if ($(this)[0].checked) {
selText .push( $(this).parent().text());
}
});
$("#selValue" + checkName).val(selText.join(","));
})
</script>
没有找到相关结果
已邀请:
个回复