<!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" xml:lang="en"> <head> <title>豪情</title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style type="text/css"> #test{width:100px;height:100px;border:1px solid #ccc;background:#eee;display:none;} </style> </head> <body> <div id="test">this is a</div> <input type="button" value="test-btn" id="btn" onclick="show('obj')" /> <script type="text/javascript"> var $ = function(id){ return document.getElementById(id); }; var obj = $('test'), btn = $('btn'); var show = function(id){$(id).style.display = 'block'; } var hide = function(id){$(id).style.display = 'none'; } btn.onclick = function(){ show('test'); } setInterval(function(){hide('test')}, 3000); </script> </body> </html>运行代码 来源:https://www.cnblogs.com/jikey/archive/2010/11/10/1874227.html 标签 xml语言