【Jquery】 實現的展開折疊效果


代碼如下:


<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>laofan</title>
  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  <style>
  .detail_content{
    display: none;
}
 
  </style>
 </head>
 <body>

<div>
	<table>
		這是表格內容
	</table>

	<div class="detail_click">  
	    展開
	</div> 

	<div class="detail_content">
	 這是詳情
	</div>
</div>



<div>
	<table>
		這是表格內容
	</table>

	<div class="detail_click">  
	    展開
	</div> 

	<div class="detail_content">
	 這是詳情
	</div>
</div>


<script type="text/javascript">
	  $('.detail_click').click(function(){
        //$(this) 為 detail_click 實體
        $(this).next().slideToggle('1000',function(){
           
            //$(this) 為 detail_content 實體
            // $(this).prev() 為 detail_click 實體
            $(this).prev().text($(this).is(":visible") ? "收起" : "展開" );

            
		});
    })
</script>

 </body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM