<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script> //para1:要隐藏的元素的id function toggle1(para1) { jQuery("#"+para1).toggle(); } </script> </head> <body> <p>点击div1,将在下面显示或隐藏div2</p> <div onclick="toggle1('div2')" id="div1">div1</div> <!-- 此处display默认为none,如果已开始要显示着,改为block --> <div id="div2" style="display:none">div2</div> </body> </html>