js如何实现复选框的多级联动

JavaScript022

js如何实现复选框的多级联动,第1张

1、为 复选框的 onclick 事件 绑定js 方法

2、在 js 方法中,判断复选框当前值

2.1、如果选中,将关联的复选框也选中

2.2、如果没有选中,将关联的复选框取消选中

<select ng-model="selectedDistrict" ng-change="selectedUnit=''" ng-options="district.name for district in districts" class="ng-valid ng-dirty"></select>

<select ng-model="selectedUnit" ng-change="selectedPosition=''" ng-options="unit.name for unit in selectedDistrict.units" class="ng-valid ng-dirty"></select>

这个是两级联动。如果要多选,建议你用插件isteven-multi-select。