1、鼠标移动到父级显示子级
<style type="text/css">
.father .child{
display:none;
}
.father:hover .child{
display:block;
z-index: 6;
}
</style>
<body>
<div class="father">鼠标移进来有惊喜哦
<p class="child">我是那个隐藏的小惊喜,鼠标引进来我就出现啦</p>
</div>
</body>
2、原生js显示隐藏
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
/**js 方式**/
function myFunction(){
var displayDiv = document.getElementById("myModal").style.display;
if (displayDiv == "none") {
document.getElementById("myModal").style.display="block";//显示
} else {
document.getElementById("myModal").style.display="none";//隐藏
}
}
</script>
<!-- jquery 方式
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
function myFunction(){
console.log("1212")
console.log($("#myModal")[0].style.display)
var displayDiv = $("#myModal")[0].style.display;
if (displayDiv == "none") {
$("#myModal").css("display","block");//显示
} else {
$("#myModal").css("display","none");//隐藏
}
}
</script>
-->
</head>
<body>
<input type="button" onclick="myFunction()" value="显示警告框" />
<div id="myModal">sdjfklsjdkflsdlfjls</div>
</body>
</html>