2013-08-03 128 views
0

我使用jquery插件dotdotdot在一段文字後創建'... Read More >>'。 當用戶點擊鏈接('read more >>')時,div必須展開才能看到整個文本。第一部分工作很好,但我無法弄清楚第二部分。將父母的身高改爲孩子的身高

這是我的代碼:

<script type="text/javascript" language="javascript" src="js/jquery.min.js"></script> 
<script type="text/javascript" language="javascript" src="js/jquery.dotdotdot.min.js"></script> 
<script type="text/javascript" language="javascript"> 
     $(function() { 
      $('#dot3').dotdotdot({ 
       after: 'a#test' 

      }); 
     }); 
<style type="text/css" media="all"> 
     div.example { 
      padding: 0 0 150px 0; 
     } 
     div.example:after { 
      content: ''; 
      display: block; 
      clear: both; 
     } 
     div.r { 
      width: 275px; 
     } 
     div.box { 
      border: 1px solid #ccc; 
      height: 160px; 
      padding: 15px 20px 10px 20px; 
      overflow:visible; 
     } 
</style> 
<div class="example"> 
      <div class="r"> 
       <div class="box after" id="dot3">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. 
        <a href="#" id="test" onClick="">Read more &raquo;</a></div> 
      </div> 
     </div> 
+0

什麼是第二部分,在div擴大?你還可以解釋一下這個標題嗎? – Chris

+0

lorem文本顯示爲'Lorem ips ... Read More >>'。這由dotdotdot插件和css設置完成。如果單擊閱讀更多>>鏈接,則應顯示整個文本。我試圖將div.box的高度更改爲自動,但不起作用。 –

回答

0

只要打電話給破壞,並調整股利。 嘗試

$("#test").click(function() { 
    var div = $('#dot3'); 
    div.trigger('destroy'); 
    div.css("height", "auto"); 
}); 

Here is fiddle.

+0

正是我在找的東西。日Thnx! –

相關問題