js点击隐藏和显示div

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>display</title>
    <script type="text/javascript"> 
        function hidetext()  
		{  
		var mychar = document.getElementById("con").style.display ="none";
        
		}  
		function showtext()  
		{  
		var mychar = document.getElementById("con").style.display ="block";
        
		}
    </script> 
</head> 
<body>  
    <h1>JavaScript</h1>  
    <p id="con">做为一个Web开发师来说,如果你想提供漂亮的网页、令用户满意的上网体验,JavaScript是必不可少的工具。</p> 
    <form>
       <input type="button" οnclick="hidetext()" value="隐藏内容" /> 
       <input type="button" οnclick="showtext()" value="显示内容" /> 
    </form>
</body> 
</html>

商务通弹窗修改,打开网页5秒后弹窗,点击关闭,5秒后再次弹窗

function showtext()  
{  
var mychar = document.getElementById("bar1").style.display ="block";
              
        }


setTimeout("showtext()",6000);//6秒 
  function hidetext()  
{  
var mychar = document.getElementById("bar1").style.display ="none";
                setTimeout("showtext()",6000);//6秒  
}  


document.writeln("<style type=\'text/css\'>");
document.writeln(".dialog{");
document.writeln(" position: fixed;");
document.writeln(" _position:absolute;");
document.writeln(" z-index:999999;");
document.writeln(" top: 50%;");
document.writeln(" left: 50%;");
document.writeln(" display: none;");
document.writeln(" margin: -135px 0 0 -140px;");
document.writeln(" width: 280px;");
document.writeln(" height:270px;");
document.writeln(" background:#339933;");
document.writeln("} ");
document.writeln(".guanbi{ top:0px; height:25px; width:30px; right:0px; position:absolute; 


cursor:pointer}");
document.writeln("</style>");
document.writeln("<div class=\'dialog\' id=\'bar1\'><span class=\'guanbi\' οnclick=\'hidetext()\'></span><a href=\'/swt/\'><img src=\'/swt/1.gif\'/></a></div>");


  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值