2013-04-29 201 views
2

我一直試圖使用jquery的dotdotdot方法來切斷溢出的文本,但由於某種原因,它不工作。我希望這種方法很簡單,但我不知道我做錯了什麼。jquery .dotdotdot無法正常工作

的Javascript:

$(document).ready(function(){ 
    $('.dotdotdot').dotdotdot({ 
     ellipsis: '... ', 
     wrap: 'word', 
     after: null, 
     watch: true, 
     height: 40 
    }); 
}); 

HTML:

<div class="dotdotdot"> 
    <?php echo $description; /*Current div height with text exceeds 40px*/ ?> 
</div> 

我找不到任何可以解釋爲什麼這是行不通的。我的jquery是最新版本1.8.3。

+6

這不是一個標準的jQuery函數。你有沒有提供它的插件? – JJJ 2013-04-29 17:22:20

+1

此外,jQuery 1.8.3不再是「最新」的。 – JJJ 2013-04-29 17:25:23

+0

@Juhana什麼是最新版本? – Alex 2013-04-29 17:35:24

回答

3

dotdotdot是一個jQuery插件,您需要單獨下載幷包含該JS也應該工作。有關更多詳細信息,請參閱http://dotdotdot.frebsite.nl/

+0

好的,這樣做更有意義。謝謝 – Alex 2013-04-29 17:26:10