【发布时间】:2018-07-16 03:08:06
【问题描述】:
我正在使用带有集成 JQuery 的 Angular 4,一旦选择了下拉字段,则包含下拉复选框的表单不应更改,即使我重新加载页面或直到我重新选择。
dropdown.html:
<div class="chkdropdown">
Show and Hide Columns
<ul>
<li>
<input type="checkbox" class="hidecol" value="name" id="col_2" /> S NO
</li>
<li>
<input type="checkbox" class="hidecol" value="name" id="col_3" /> DrugName
</li>
<li>
<input type="checkbox" class="hidecol" value="salary" id="col_4" /> Generic Name
</li>
<li>
<input type="checkbox" class="hidecol" value="gender" id="col_5" /> Generic Combination
</li>
<li>
<input type="checkbox" class="hidecol" value="city" id="col_6" /> Dosage
</li>
<li>
<input type="checkbox" class="hidecol" value="email" id="col_7" /> VAT
</li>
</ul>
</div>
ang.component.ts:
$(document).ready(function(){
$(".hidecol").click(function(){
var id = this.id;
var splitid = id.split("_");
var colno = splitid[1];
var checked = true;
if($(this).is(":checked")){
checked = true;
}else{
checked = false;
}
setTimeout(function(){
if(checked){
$('#drug_table td:nth-child('+colno+')').hide();
$('#drug_table th:nth-child('+colno+')').hide();
} else{
$('#drug_table td:nth-child('+colno+')').show();
$('#drug_table th:nth-child('+colno+')').show();
}
}, 500);
});
});
【问题讨论】:
标签: jquery angular checkbox jquery-plugins