用jQuery toggle函数控制div显示与隐藏
canrun
View Code
<!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>点击消失的DIV</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <script type="text/javascript" src="https://files.cnblogs.com/Zjmainstay/jquery-1.6.2.min.js"></script> </head> <body> <style> #adBlock{ display:block; width:200px; height:300px; border:1px solid; float:left; } #clickController{ border: 1px solid #AABBCC; display: block; float: left; height: 80px; padding: 1px; width: 16px; } </style> <div id="adBlock"></div> <div id="clickController"><< 点击我</div> <script type="text/javascript"> $(document).ready(function(){ $("#clickController").click(function(){ ($(this).text()=='>> 点击我')?$(this).text('<< 点击我'):$(this).text('>> 点击我'); $("#adBlock").toggle(500); }); }); </script> </body> </html>