熟悉position的用法
<!doctype html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<script src=”http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js”></script>
<script src=”jquery/jquery-1.11.3.min.js”></script>
<title>输入框获得焦点,显示div 点击别处div隐藏</title>
</head>
<style>
.page_modal{
position: absolute;
top:0px;
left:0px;
border:1px solid red;
width:100%;
height:100%;
display:none;
z-index:2000;
}
.div_text{
width:200px;
position: absolute;
margin:0px;
padding:0px;
background-color:blue;
display:none;
z-index:2001;
opacity:0.5;
}
a{
}
a:hover{
cursor:pointer;
color:black;
}
</style>
<body>
<div>
<input type=”text” id=”inp_only”onmouseover=”$(‘#div_show’).show();”onmouseout=”$(‘#div_show’).hide();” onfocus=”inpFocus()” onkeyup=”inpFocus()”/>
</div>
<div class=”div_text” id=”div_show” onmouseover=”$(‘#div_show’).show();” onmouseout=”$(‘#div_show’).hide();”></div>
<div class=”page_modal”></div>
</body>
<script>
$(function(){
$(“.page_modal”).click(function(){
//$(“.page_modal”).hide();
$(“#div_show”).hide();
});
})
$(“#div_show>a”).click(function(){
var textVal = $(this).val();
//$(“.page_modal”).hide();
$(“#div_show”).hide();
$(“#inp_only”).val(textVal);
})
function inpFocus(){
$(“#div_show”).html(“”);
var $a = “”;
for(var i=0;i<5;i++){
$a += “<a href=’javascript:void(0);’ style=’display:block;color:white’>1.1.1.”+i+”</a>”;
}
$(“#div_show”).append($a);
//$(“.page_modal”).show();
$(“#div_show”).show();
}
</script>
</html>