jquery .dotdotdot is not working

5.5k Views Asked by At

I've been trying to use jquery's dotdotdot method in order to cut off overflowed text, but for some reason it's not working. I was hoping the method would be pretty simple, but I don't know what I'm doing wrong.

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>

I cant find anything that would explain why this isn't working. My jquery is up to date, version 1.8.3.

2

There are 2 best solutions below

0
dexterous On BEST ANSWER

dotdotdot is a jQuery plugin which you need to download separately and include that JS also then it should work. Refer to http://dotdotdot.frebsite.nl/ for more details.

1
Tim B James On

Depending on your needs, you could just use the text overflow property ellipses

See this website for more details, and an example.

http://www.quirksmode.org/css/user-interface/textoverflow.html