1. 程式人生 > 其它 >js模擬title效果,程式碼實現

js模擬title效果,程式碼實現

技術標籤:jsjavascriptcsshtml5

	網上看了幾個帖子,自己就寫了一個,比較簡單的,只有大概功能,詳細部分還要根據自己的需求新增和修改。
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>模擬title</title>
<style>
	.div1{
		height:100px;
		width:200px;
		background-color: aqua;
	}
	.div2{
		height:100px;
width:200px; background-color: aqua; } .div2 div{ display:none; } .div3{ width:70px; text-align:center; margin-left:17px; float:left; background-color:#afb7ae; margin-top:17px; font-size:17px; border-radius:3px;}
</style> <script> window.onload = function(){ var d = document.
getElementById("d"); var t = document.getElementById("t"); var timer; d.onmouseover = function(){ timer=setTimeout(function(){t.style.display='initial';},800); }; d.onmouseout = function(){ clearTimeout(timer); t.style.display = "none"; }; };
</script
>
<body> <div class="div1" title="系統title">指向此處顯示title1</div> -------------- <div id="d" class="div2">指向此處顯示title2 <div id="t" class="div3">模擬title</div> </div> </body> </html>
	還有個比較重要的效果沒帶上,就是title顯示的位置,比較好弄懶得加了。