本文实例讲述了jquery实现简单合拢与展开网页面板的方法。分享给大家供大家参考。具体如下:
这是一款网页上常见的合拢(收缩)、伸展面板代码,使用了jQuery插件,代码更加简化,点击面板的标题栏即可折叠、或展开这个层,是网上很流行的效果,由此可扩展出的功能还真挺多,只要动脑筋,一定能做出来。
运行效果截图如下:
在线演示地址如下:
http://demo.phpstudy.net/js/2015/jquery-simple-hidden-show-web-table-codes/
具体代码如下:
<!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> <style type=\"text/css\"> *{margin:0;padding:0;} body { font-size: 13px; line-height: 130%; padding: 60px } #panel { width: 300px; border: 1px solid #0050D0 } .head { padding: 5px; background: #96E555; cursor: pointer } .content { padding: 10px; text-indent: 2em; border-top: 1px solid #0050D0;display:block; } </style> <script type=\"text/javascript\" src=\"jquery-1.6.2.min.js\"></script> <script type=\"text/javascript\"> $(function(){ $(\"#panel h5.head\").toggle(function(){ $(this).next(\"div.content\").hide(); },function(){ $(this).next(\"div.content\").show(); }) }) </script> </head> <body> <div id=\"panel\"> <h5 class=\"head\">点击此处标题可展开</h5> <div class=\"content\"> 一款基于jquery的伸展面板代码,点击面板的标题栏即可折叠、或展开这个层,貌似网上很流行的效果,引用了jQuery插件,使得本款效果更加的简洁实用, </div> </div> </body> </html>
希望本文所述对大家的jquery程序设计有所帮助。
本文地址:https://www.stayed.cn/item/19970
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我