1. 程式人生 > >js react 全選和反選

js react 全選和反選

.get document con asc cli length record bin highlight

onCheckAll = (data) => {
		var CheckBox  = document.getElementsByName(data);
		for(let i=0;i<CheckBox.length;i++){
            if(CheckBox[i].checked==true){
                     CheckBox[i].checked=false;
            } else{
                 CheckBox[i].checked=true
            }
        };
	}



const columnWBS = [
			{title:‘WBS節點名稱‘,dataIndex:‘label‘},
			{title:‘權限‘,dataIndex:‘qx‘,
			render: (text, record, index) =>(
		      	<span >
			      	<Button size="small" onClick={this.onCheckAll.bind(this,record.key)} style={{marginRight:‘5px‘}}> 全選</Button>
			      	<span id="checkBoxWrap">
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 添加
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 刪除
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 編輯
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 查看
				    </span>
		      	</span>
			
			)}]

  

js react 全選和反選