標籤:簡單 utf-8 span func ext charset isp class round
<!doctype html><html lang="en"><head> <meta charset="UTF-8" /> <title>Document</title> <link rel="stylesheet" type="text/css" href="./css/a1.css"> <script src="./js/jquery.min.js"></script> <style> .title{ width: 300px; height: 40px; line-height: 40px; background: #333; text-indent: 2em; color: #fff; margin-top: 2px;}.content{ width: 298px; border: 1px solid #333; display: none;}.active{ background: #999;} </style></head><body> <div class="title">aaaaaa</div> <div class="content"> <p>aaaaaaaaaaaaaaa</p> <p>aaaaaaaaaaaaaaa</p> <p>aaaaaaaaaaaaaaa</p> <p>aaaaaaaaaaaaaaa</p> <p>aaaaaaaaaaaaaaa</p> <p>aaaaaaaaaaaaaaa</p> </div> <div class="title">bbbbbb</div> <div class="content"> <p>bbbbbbbbbbbbbbb</p> <p>bbbbbbbbbbbbbbb</p> <p>bbbbbbbbbbbbbbb</p> <p>bbbbbbbbbbbbbbb</p> <p>bbbbbbbbbbbbbbb</p> <p>bbbbbbbbbbbbbbb</p> </div> <div class="title">cccccc</div> <div class="content"> <p>ccccccccccccccc</p> <p>ccccccccccccccc</p> <p>ccccccccccccccc</p> <p>ccccccccccccccc</p> <p>ccccccccccccccc</p> <p>ccccccccccccccc</p> </div></body><script src="./js/a1.js">//$(".title") 選擇對象//click() 觸發條件//function(){} 操作函數$(".title").click(function(){ $(this).next().slideToggle(1000); //設定下拉需要的時間 $(this).toggleClass("active"); //<div class="title">aaaaaa</div>,增加一個class title,<div class="title active"></div>});</script></html>
jquery邏輯的簡單例子