Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.
/ jquery-truncate Public archive
forked from tbasse/jquery-truncate

Simple plugin that truncates a text either at its end or middle based on a given width or it's elements width.

Notifications You must be signed in to change notification settings

kuzeko/jquery-truncate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple plugin that truncates a text either at its end or middle based on a given width or it's elements width. The width calculation takes into account all the original elements css styles like font-size, font-family, font-weight, text-transform, letter-spacing etc.

Additionally if the text has been shortened you can set a class to be appended to the element and/or set the "title" attribute to the original text.

Usage

$('.class').truncate();

$('.class').truncate({
	width: 'auto',
	token: '…',
	center: false,
});

Options

  • width (int) Width to which the text will be shortened [default: auto]
  • token (string) Replacement string for the stripped part [default: '…']
  • center (bool) Shortens at the center of the string if set to 'true' [default: false]
  • addclass (string) Add a class to the truncated strings element [default: false]
  • addtitle (bool) Add/Set "title" attribute with original text to the truncated strings element [default: false]

About

Simple plugin that truncates a text either at its end or middle based on a given width or it's elements width.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%