鼠标在图片上,显示文字,移开文字隐藏的js代码
3个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script>
$(function(){
$("#div1").hover(function(){
$(this).find("span").show();
},function(){
$(this).find("span").hide();
})
})
</script>
<style>
#div1 {width:200px; height:200px;position:relative;border:1px solid #ddd;margin:0;}
#div1 img{ width:200px; height:200px;}
#div1 span{ position:absolute; top:0; left:0; width:100%; height:100%; display:none; background:rgba(0,0,0,.3); z-index:1; color:#FFF;}
</style>
</head>
<body>
<div id="div1">
<img src="http://img2.niushe.com/upload/201306/26/11-51-25-86-59983.jpg" />
<span>这里是文字文字</span>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询