【JQuery】不超過一頁的FAQ–收合功能
使用JQuery前,需要引用Jquery元件。 HTML 頁面(參考)︰ <div class=" main "> <h1>A One Page FAQ</h1> <h2> I've heard that JavaScript is the long-lost fountain of youth. Is this true? </h2> <div class=" answer "> <p>Why, yes it is! Studies prove that learning JavaScript freshens the mind and extends life span by several hundred years. (Note: some scientists disagree with these claims.)</p> </div> <h2> Can JavaScript really solve all of my problems? </h2> <div class=" answer "> <p>Why, yes it can! It's the most versatile programming language ever created and is trained to provide financial management advice, life-saving CPR, and even to take care of household pets.</p> </div> .... 省略之 ..... </div> Javascript︰ <SCRIPT type="text/javascript"> $(document).ready(function() { $(' .answer ').hide(); //隱藏 $(' .main h2 ').toggle( function(...