我试图获取每个选中的复选框的值为true。每次我选择一个复选框时,它会抓取该复选框的值而不是所有选中的复选框。获取每个选中的复选框的值
路径:talentList.html
<fieldset>
<div class="checkbox">
<label>
<input name="specialisation" type="checkbox" value="Accounting Firm"> Accounting Firm
</label>
</div>
<div class="checkbox">
<label>
<input name="specialisation" type="checkbox" value="Accounting in Industry"> Accounting in Industry
</label>
</div>
</fieldset>
路径:talentList.js
Template.talentList.events({
'change [name="specialisation"]': function (event, template) {
let specialisation = event.target.value;
template.candidateListFilter.set(specialisation);
}
});
我不清楚你的问题是什么。您是否试图在选择复选框时获取所有选中的复选框值? – Khang
是的,这是正确的 – bp123