A simple jQuery tooltip plugin.
$ cnpm install @fengyuanchen/tooltip
A simple jQuery tooltip plugin.
dist/
├── tooltip.css (2 KB)
├── tooltip.min.css (2 KB)
├── tooltip.js (9 KB)
└── tooltip.min.js (4 KB)
Three quick start options are available:
git clone https://github.com/fengyuanchen/tooltip.git.npm install @fengyuanchen/tooltip.Include files:
<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<link href="/path/to/tooltip.css" rel="stylesheet">
<script src="/path/to/tooltip.js"></script>
Initialize with $.fn.tooltip method.
// With option
$('body').tooltip({
autoshow: true,
content: 'Hello, world!'
});
// With method
$('body').tooltip('show', 'Hello, world!');
// Shortcut
$('body').tooltip('Hello, world!');
// Set tooltip options
$().tooltip(options);
// Change the global default options
$.fn.tooltip.setDefaults(options);
BooleantrueHide the tooltip automatically when timeout. requires duration option to be set.
BooleantrueShow the tooltip automatically when initialize. requires content option to be set.
String''Tooltip content
BooleanfalseShow countdown view. requires duration option to be set.
BooleanfalseAllow to dismiss the tooltip by click an attached close button before it is closed automatically.
Number3000Define the time of the tooltip showing (3 seconds by default).
BooleantrueFix the tooltip (Only available for body element).
Number10Offset of the tooltip from its parent.
String'center top''left top', 'center top', 'right top',
'left middle', 'center middle', 'right middle',
'left bottom', 'center bottom', 'right bottom'Position of the tooltip (horizontal and vertical)
String'default''default', 'primary', 'success', 'info', 'warning', 'danger'Style of the tooltip
Number1024Z-index of the tooltip.
$().tooltip('method', argument1, , argument2, ..., argumentN)
StringShow the tooltip with new content.
$().tooltip('show', 'Hello, world!');
$().tooltip('show', 'Hello, world!', 'primary');
$().tooltip('show', 'Hello, world!', {
style: 'primary',
zIndex: 2048
});
Shortcut: $().tooltip(content, options)
show method$().tooltip('Hello, world!', 'primary');
Hide the tooltip.
Destroy the tooltip.
This event fires immediately when the show instance method is called.
This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).
This event is fired immediately when the hide instance method has been called.
This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).
If you have to use other plugin with the same namespace, just call the $.fn.tooltip.noConflict method to revert to it.
<script src="other-plugin.js"></script>
<script src="tooltip.js"></script>
<script>
$.fn.tooltip.noConflict();
// Code that uses other plugin's "$().tooltip" can follow here.
</script>
As a jQuery plugin, you also need to see the jQuery Browser Support.
Released under the MIT license.
Copyright 2013 - present © cnpmjs.org | Home |