Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CSS */
- .short-description p {
- height: 3em;
- }
- /* JavaScript */
- jQuery(document).ready(function($) {
- function shorten_text(selector) {
- $(selector).each(function() {
- var $elem = $(this);
- var wordArray = $elem.html().split(' ');
- while($elem.prop('scrollHeight') > $elem.prop('offsetHeight')) {
- wordArray.pop();
- $elem.html(wordArray.join(' ') + '...');
- }
- });
- }
- shorten_text('.short-description p');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement