JavaScript实现九宫格图片半透明渐显特效

作者:小圆点时间:2026-10-28 22:47:04浏览:352

本文介绍利用JavaScript实现九宫格图片的半透明渐显特效。通过定义CSS类控制初始透明度,并结合onmouseover和onmouseout事件触发JavaScript函数,利用setInterval逐步调整图片透明度,实现鼠标悬停时图片逐渐清晰的效果。

JavaScript实现九宫格图片半透明渐显特效

本文详细介绍如何使用JavaScript实现九宫格图片的半透明渐显特效,供读者参考学习。

具体实现代码如下:

<html>
<title>九宫格图片半透明渐显效果</title>
<body>
<STYLE type=text/css>.invisible {
FILTER: alpha(opacity=0)
}
</STYLE>
<SCRIPT language=JavaScript1.2>
<!--
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=0
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
//-->
</SCRIPT>
 <TABLE borderColor=#999999 cellSpacing=8 cellPadding=0 width=302 
 border=0><TBODY>
 <TR>
 <TD width=90 background=text1.gif bgColor=#db4d0e 
 height=90><A href=""><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) 
 src="/images/m01.jpg" border=0 width=180px height=135px></A></TD>
 <TD width=90 background=text2.gif bgColor=#ff9f07><A 
 href="/"><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) 
 src="/images/m02.jpg" border=0 width=180px height=135px></A></TD>
 <TD width=90 background=text3.gif bgColor=#ff9f07><A 
 href=""><IMG class=invisible 
 onmouseover=high(this) onmouseout=low(this) src="/images/m03.jpg" 
 border=0 width=180px height=135px></A></TD></TR>
 <TR>
 <TD background=text4.gif bgColor=#ff9f07><A 
 href="/"><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) 
 src="/images/m04.jpg" border=0 width=180px height=135px></A></TD>
 <TD background=text5.gif bgColor=#a5d523><A 
 href="/"><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) 
 src="/images/m05.jpg" border=0 width=180px height=135px></A></TD>
 <TD background=text6.gif bgColor=#c56e19><A 
 href=""><IMG class=invisible 
 onmouseover=high(this) onmouseout=low(this) src="/images/m06.jpg" 
 border=0 width=180px height=135px></A></TD></TR>
 <TR>
 <TD background=text12.gif bgColor=#ff9f07><A 
 href="/"><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) 
 src="/images/m07.jpg" border=0 width=180px height=135px></A></TD>
 <TD background=text8.gif bgColor=#c56e19><A 
 href="/"><IMG 
 class=invisible onmouseover=high(this) onmouseout=low(this) src="/images/m08.jpg" 
 border=0 width=180px height=135px></A></TD>
 <TD background=text7.gif bgColor=#c56e19><A 
 href=""><IMG class=invisible 
 onmouseover=high(this) onmouseout=low(this) src="/images/m09.jpg" 
 border=0 width=180px height=135px></A></TD></TR></TBODY></TABLE>
</body>
</html>

希望本文所述对大家的javascript程序设计有所帮助。

作者最新文章