Skip to content

This is a simple jQuery plugin that truncates text to a single line clipped with an ellipsis and displays a tooltip on hover.

License

Notifications You must be signed in to change notification settings

lyushenko/jquery-hover-truncated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Hover Truncated

This is a simple jQuery plugin that truncates text to a single line clipped with an ellipsis and displays a tooltip on hover.

WARNING: this repo is not maintained anymore.

Installation and usage

  1. Run bower install jquery-hover-truncated
  2. Copy styles to your stylesheet or just link an external file in your <head>:

<link rel="stylesheet" type="text/css" href="path/to/jquery.hovertruncated.css">

  1. Then, before your closing <body> tag add:
<script src="path/to/jquery.min.js"></script>
<script src="path/to/jquery.hovertruncated.js"></script>
  1. In your JS, initialize a plugin:
$(function(){
   $('.truncate').hoverTruncated();
});

Or configure it like the following:

$(function(){
  var options = {
    dataAttr:    'plugin-cache',    // data attribute to store an instance, default: 'hover-truncated'
    className:   'tooltip-plain',   // tooltip class name, default: 'hover-truncated'
    tooltipText: 'Hello, World!',   // tooltip text, default: element inner text
    offsetX:     0,                 // tooltip offset-x, default: 10px
    offsetY:     0                  // tooltip offset-y, default: 10px
  };
  $('.truncate').hoverTruncated(options);
});
  1. Then you can call a plugin method:
$(function(){
   $('.truncate').hoverTruncated('hide');                             // hides an element's tooltip
   $('.truncate').hoverTruncated('show');                             // reveals an element's tooltip
   $('.truncate').hoverTruncated('update', 'Goodbye, cruel world!');  // updates an element's tooltip content
   $('.truncate').hoverTruncated('destroy');                          // hides and destroys an element's tooltip
});

License

This plugin is released under the MIT license.

About

This is a simple jQuery plugin that truncates text to a single line clipped with an ellipsis and displays a tooltip on hover.

Resources

License

Stars

Watchers

Forks

Packages

No packages published