jQuery中ztree 点击文本框弹出下拉框的实例代码
废话不多说了,具体代码如下所示:
<linkrel="stylesheet"href="${ctx}/res/js/ztree/css/demo.css"type="text/css"/> <linkrel="stylesheet"href="${ctx}/res/js/ztree/css/zTreeStyle/zTreeStyle.css"type="text/css"/> <scripttype="text/javascript"src="${ctx}/res/js/ztree/js/jquery.ztree.core-3.5.js"></script>
<inputonclick="showMenu();returnfalse;"/>
varsetting={ view:{ dblClickExpand:false }, data:{ simpleData:{ enable:true } }, callback:{ onClick:onClick } }; functiononClick(e,treeId,treeNode){ varzTree=$.fn.zTree.getZTreeObj("treeDemo"), nodes=zTree.getSelectedNodes(); menuName=""; menuId=""; nodes.sort(functioncompare(a,b){returna.id-b.id;}); varisParent=nodes[0].getParentNode(); varisChildren=nodes[0].children; if((!isParent&&!isChildren)||(isParent)){ for(vari=0,l=nodes.length;i<l;i++){ menuName+=nodes[i].name+","; menuId+=nodes[i].id+","; } if(menuName.length>0)menuName=menuName.substring(0,menuName.length-1); if(menuId.length>0)menuId=menuId.substring(0,menuId.length-1); $("#menuName").val(menuName); $("#menuId").val(menuId); } } functionshowMenu(){ varcityObj=$("#menuName"); varcityOffset=$("#menuName").offset(); $("#menuContent").css({left:cityOffset.left+"px",top:cityOffset.top+cityObj.outerHeight()+"px"}).slideDown("fast") $("body").bind("mousedown",onBodyDown); varwidth=cityObj.css("width"); $("#treeDemo").css("width",parseInt(width)-5); } functionhideMenu(){ $("#menuContent").fadeOut("fast"); $("body").unbind("mousedown",onBodyDown); } functiononBodyDown(event){ if(!(event.target.id=="menuContent"||$(event.target).parents("#menuContent").length>0)){ hideMenu(); } } $(document).ready(function(){ $.fn.zTree.init($("#treeDemo"),setting,zNodes); });
以上所述是小编给大家介绍的jQuery中ztree点击文本框弹出下拉框的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!