复主代码 代码如下: 复主代码 代码如下: 复主代码 代码如下: <br> var zTree1;<br> var setting = {<br> isSimpleData: true,<br> treeNodeKey: "id",<br> treeNodeParentKey: "pId",<br> fontCss: setFont,<br> callback: {<br> beforeClick: zTreeOnBeforeClick,<br> click: zTreeOnClick<br> } <br> };<br> var zNodes = [<br> {id:1, pId:0, name:"北京"},<br> {id:2, pId:0, name:"天津"},<br> {id:3, pId:0, name:"上海"},<br> {id:6, pId:0, name:"重庆"},<br> {id:4, pId:0, name:"河北省", open:true},<br> {id:41, pId:4, name:"石家庄"},<br> {id:42, pId:4, name:"保定"},<br> {id:43, pId:4, name:"邯郸"},<br> {id:44, pId:4, name:"承德"},<br> {id:5, pId:0, name:"广东省", open:true},<br> {id:51, pId:5, name:"广州"},<br> {id:52, pId:5, name:"深圳"},<br> {id:53, pId:5, name:"东莞"},<br> {id:54, pId:5, name:"佛山"},<br> {id:6, pId:0, name:"福建省", open:true},<br> {id:61, pId:6, name:"福州"},<br> {id:62, pId:6, name:"厦门"},<br> {id:63, pId:6, name:"泉州"},<br> {id:64, pId:6, name:"三明"}<br> ];<br> <p> function setFont(treeId, treeNode) {<br> if (treeNode && treeNode.isParent) {<br> return {color: "blue"};<br> } else {<br> return null;<br> }<br> }<br> function showMenu(){<br> var cityObj = $("#citySel");<br> var cityOffset = $("#citySel").offset();<br> $( "#DropdownMenuBackground").css({left:cityOffset.left "px",top:cityOffset.top cityObj.outerHeight() "px"}).slideDown("fast"); <br> } <br> 함수 reloadTree(){<br> hideMenu();<br> zTree1 = $("#dropdownMenu").zTree(setting, zNodes);<br> }<br> 함수 hideMenu() {<br> $("#DropdownMenuBackground").fadeOut("fast");<br> }<br> function zTreeOnBeforeClick(treeId, treeNode) {<br> var check = (treeNode && !treeNode.isParent);<br> if (!check) Alert("只能选择citycity...");<br> return check;<br> }<br><br> function zTreeOnClick(event, treeId, treeNode) {<br> if (treeNode) {<br> var cityObj = $("#citySel");<br> cityObj.attr("value", treeNode.name);<br> hideMenu();<br> }<br> }<br><br> $(document).ready(function(e) {<br> reloadTree();<br> $("#menuBtn").bind("click",<br> function(){<br>> {<br> hideMenu();<br> }<br> }<br> );<br> $("body").bind("mousedown", <br> function(event){<br> if (!(event.target.id == " 드롭다운메뉴배경 " || $(event.target).parents("#DropdownMenuBackground").length>0)) {<br> hideMenu();<br> }<br> }); <br> });<br>