故里桃花落无踪,小楼轩窗山影重。若见瘦湖病西子,凋零秋风映山红。正是荷花成熟的季节,一朵朵荷花含苞怒放,满田野里的荷田闪烁着金光,一簇簇的荷花有的带着水珠乍开,有的含苞吐蕾,有的像个含羞的少女似开非开。
废话不多说了,具体代码如下所示:
<link rel="stylesheet" rel="nofollow noopener noreferrer" href="${ctx}/res/js/ztree/css/demo.css" type="text/css"/> <link rel="stylesheet" rel="nofollow noopener noreferrer" href="${ctx}/res/js/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/> <script type="text/javascript" src="${ctx}/res/js/ztree/js/jquery.ztree.core-3.5.js"></script>
<input onclick="showMenu();return false;"/>
var setting = { view: { dblClickExpand: false }, data: { simpleData: { enable: true } }, callback: { onClick: onClick } }; function onClick(e, treeId, treeNode) { var zTree = $.fn.zTree.getZTreeObj("treeDemo"), nodes = zTree.getSelectedNodes(); menuName = ""; menuId = ""; nodes.sort(function compare(a,b){return a.id-b.id;}); var isParent = nodes[0].getParentNode(); var isChildren = nodes[0].children; if((!isParent && !isChildren) || (isParent)){ for (var i=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); } } function showMenu() { var cityObj = $("#menuName"); var cityOffset = $("#menuName").offset(); $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast") $("body").bind("mousedown", onBodyDown); var width = cityObj.css("width"); $("#treeDemo").css("width",parseInt(width)-5); } function hideMenu() { $("#menuContent").fadeOut("fast"); $("body").unbind("mousedown", onBodyDown); } function onBodyDown(event) { if (!(event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) { hideMenu(); } } $(document).ready(function(){ $.fn.zTree.init($("#treeDemo"), setting, zNodes); });
以上所述是小编给大家介绍的jQuery中ztree 点击文本框弹出下拉框的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
到此这篇关于jQuery中ztree 点击文本框弹出下拉框的实例代码就介绍到这了。抬起一只脚,身倾后方击球最要不得——击球无力,不能迅速回防,予敌可乘之机,会闪腰,姿势也难看。更多相关jQuery中ztree 点击文本框弹出下拉框的实例代码内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!