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

    
//此处在div中的ul是一个ztree树
var html='<div id="'+btnName+'DropDown" style="display: none;position:absolute; height:200px; min-width: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"); } } );

 

posted @ 2018-05-26 16:19  charliepan94  阅读(2140)  评论(0编辑  收藏  举报