纯JS ,发一个区块切换效果,欢迎修改,不用JQ插件
<!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>
<title>this is  event test</title>
<style>
#test1 {cursor:pointer;}
</style>
<script type="text/javascript" language="javascript">
    /* 页面切换效果 */
    function JumpDiv(id) { window.obj = this; this.Did = id; this.Count = 0; this.Jump = function() { obj.Count = obj.Count + 5; if (obj.Count < 100) { setTimeout("obj.Jump()", 1); var o = document.getElementById(obj.Did); if (o) { var str = "Alpha(opacity=" + this.Count + ")"; o.style.filter = str; } } } }
    
    function test(o){
if(o){
var i=Math.floor(Math.random()*1000+100);
var j=new JumpDiv(o.id);
o.innerHTML=i;
j.Jump();
}    }</script>
</head>
<body onselectstart="return false">
<h1 id="test1" onclick="test(this)">test is start</h1>
</body></html>

解决方案 »

  1.   

    这个兼容FF
        /* 页面切换效果 */
        function JumpDiv(id) { window.obj = this; this.Did = id; this.Count = 5; this.Jump = function() { obj.Count = obj.Count + 5; if (obj.Count < 100) { setTimeout("obj.Jump()", 1); var o = document.getElementById(obj.Did); if (o) { if(navigator.userAgent.indexOf("Firefox") > -1) o.style.opacity = this.Count /100 ;  else o.style.filter = "Alpha(opacity=" + this.Count + ")"; } } } }