本文實例講述了jquery實現簡單合攏與展開網頁面板的方法。分享給大家供大家參考。具體如下:
這是一款網頁上常見的合攏(收縮)、伸展面板代碼,使用了jQuery插件,代碼更加簡化,點擊面板的標題欄即可折疊、或展開這個層,是網上很流行的效果,由此可擴展出的功能還真挺多,只要動腦筋,一定能做出來。
運行效果截圖如下:
在線演示地址如下:
http://demo.VeVB.COm/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程序設計有所幫助。
新聞熱點
疑難解答