Home > Web Front-end > JS Tutorial > body text

zTree click text to check the checkbox

黄舟
Release: 2017-02-18 13:23:40
Original
2077 people have browsed it

1. Problem background

## The system uses the zTree plug-in to generate a drop-down check tree, click on the text to check the check box


2. Implementation source code

##

<!DOCTYPE html>
<html>
<head>
	<title>zTree点击文字勾选复选框</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" href="../../../css/demo.css" type="text/css">
	<link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../../../js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			//初始化树
			zTree = $.fn.zTree.init($("#treeSelect"), setting, datas);
		});
	
		//设置
		var setting = {
			check: {
				enable: true
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: { 
			 	onClick: function (e, treeId, treeNode, clickFlag) { 
			 		zTree.checkNode(treeNode, !treeNode.checked, true); 
			 	} 
			},
    	}, zTree;

		//数据
		var datas =[
			{ id:1, pId:0, name:"树", open:true},
			{ id:11, pId:1, name:"松树", open:true},
			{ id:12, pId:1, name:"樟树", open:true},
			{ id:2, pId:0, name:"花", checked:true, open:true},
			{ id:21, pId:2, name:"梅花"},
			{ id:22, pId:2, name:"桃花", open:true}
		];
	</script>
</head>

<body>
	<p style="vertical-align: middle; text-align: center;">
		<p>
			<ul id="treeSelect" class="ztree"></ul>
		</p>
	</p>
</body>
</html>
Copy after login

3. Implementation result


   

zTree click text to check the checkbox

The above is the content of zTree when you click on the text to check the check box. For more related information, please Follow the PHP Chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!