Find us on Google+ Kill the code: Image changer in Javascript using Z-Index

Sunday 4 March 2012

Image changer in Javascript using Z-Index

Preview :
New Web Project







Code :







<html>
    <head>         <title>New Web Project</title>         <style type="text/css">         #block img {         position:absolute;         left:10px;         top:10px;         z-index:0;         }         #but {         margin-left: 300px;         margin-top: 300px;         }         </style>     </head>     <body>     <script type="text/javascript">     var b = 0;     function change() {     b++;     var a = document.getElementById(b%5);     a.style.zIndex = b;     return;     }     function call() {     var c = setInterval("change()",1000);     return;     }     </script>         <div id="block">         <img src="4.png" id="4"/>         <img src="3.png" id="3"/>         <img src="2.png" id="2"/>         <img src="1.png" id="1"/>         </div>         <input type="button" id="but" onclick="return call()" value="change">     </body> </html>

1 comment: