点击input框时,在input框下边展示一个div

    
//此处在div中的ul是一个ztree树
var html='<div id="'+btnName+'DropDown" style="display: none;position:absolute; height:200px; min-150px; background-color:white;border:1px solid;overflow-y:auto;overflow-x:auto;z-index: 999999">'+ '<ul id="'+btnName+'Tree" class="ztree"></ul>'+ '</div>' $("body").append(html); //站点文本框点击事件 $btn.click(function () { var stationObj = $btn; var stationOffset = $btn.offset(); $("#"+btnName+"DropDown").css({left:stationOffset.left + "px", top:stationOffset.top + stationObj.outerHeight() + "px"}).slideDown("fast"); });   //站点选择失去焦点 $("body").bind("mousedown", function(event){ if (!(event.target.id == btnName || event.target.id == btnName+"DropDown" || $(event.target).parents("#"+btnName+"DropDown").length>0)) { $("#"+btnName+"DropDown").fadeOut("fast"); } } );
原文地址:https://www.cnblogs.com/charliepan/p/9093200.html