js实现放在div上显示,离开隐藏
鼠标放在文字上显示,离开文字隐藏,代码如下
<html>
<head>
<title></title>
</head>
<style>
#div1{
width:100px;
height:200px;
background:red;
display:none;
}
</style>
<script>
function show(){
document.getElementById('div1').style.display='block'
}
function hide(){
document.getElementById('div1').style.display='none'
}
</script>
<body>
<div onmouseover="show()" onmouseout="hide()">显示/隐藏</div>
<div id="div1"></div>
</body>
</html>