@fengyuanchen/tooltip

中文文档
0.0.2发布于 2015/08/09MITCommonJS近 30 天下载 2.2万

A simple jQuery tooltip plugin.

此软件包已被标记为弃用

No longer maintainted.

原始使用文档
文档目录29 节
  1. Main
  2. Getting started
  3. Quick start
  4. Installation
  5. Usage
  6. Options
  7. autohide
  8. autoshow
  9. content
  10. countdown
  11. dismissible
  12. duration
  13. fixed
  14. offset
  15. position
  16. style
  17. zIndex
  18. Methods
  19. show([content[, options]])
  20. hide()
  21. destroy()
  22. Events
  23. show.tooltip
  24. shown.tooltip
  25. hide.tooltip
  26. hidden.tooltip
  27. No conflict
  28. Browser Support
  29. License

Tooltip

A simple jQuery tooltip plugin.

Main

dist/
├── tooltip.css     (2 KB)
├── tooltip.min.css (2 KB)
├── tooltip.js      (9 KB)
└── tooltip.min.js  (4 KB)

Getting started

Quick start

Three quick start options are available:

  • Download the latest release.
  • Clone the repository: git clone https://github.com/fengyuanchen/tooltip.git.
  • Install with NPM: npm install @fengyuanchen/tooltip.

Installation

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>

Usage

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!');

Options

// Set tooltip options
$().tooltip(options);

// Change the global default options
$.fn.tooltip.setDefaults(options);

autohide

  • Type: Boolean
  • Default: true

Hide the tooltip automatically when timeout. requires duration option to be set.

autoshow

  • Type: Boolean
  • Default: true

Show the tooltip automatically when initialize. requires content option to be set.

content

  • Type: String
  • Default: ''

Tooltip content

countdown

  • Type: Boolean
  • Default: false

Show countdown view. requires duration option to be set.

dismissible

  • Type: Boolean
  • Default: false

Allow to dismiss the tooltip by click an attached close button before it is closed automatically.

duration

  • Type: Number
  • Default: 3000

Define the time of the tooltip showing (3 seconds by default).

fixed

  • Type: Boolean
  • Default: true

Fix the tooltip (Only available for body element).

offset

  • Type: Number
  • Default: 10

Offset of the tooltip from its parent.

position

  • Type: String
  • Default: 'center top'
  • Options: '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)

style

  • Type: String
  • Default: 'default'
  • Options: 'default', 'primary', 'success', 'info', 'warning', 'danger'

Style of the tooltip

zIndex

  • Type: Number
  • Default: 1024

Z-index of the tooltip.

Methods

$().tooltip('method', argument1, , argument2, ..., argumentN)

show([content[, options]])

  • content (optional):
  • options (optional):
    • Type: String or Object
    • Tooltip's style or tooltip's options

Show 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)

  • Only for show method
  • The first argument must be a string (not one of the methods)
$().tooltip('Hello, world!', 'primary');

hide()

Hide the tooltip.

destroy()

Destroy the tooltip.

Events

show.tooltip

This event fires immediately when the show instance method is called.

shown.tooltip

This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).

hide.tooltip

This event is fired immediately when the hide instance method has been called.

hidden.tooltip

This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).

No conflict

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>

Browser Support

  • Chrome (latest 2)
  • Firefox (latest 2)
  • Internet Explorer 8+
  • Opera (latest 2)
  • Safari (latest 2)

As a jQuery plugin, you also need to see the jQuery Browser Support.

License

Released under the MIT license.

版本与发布记录

@fengyuanchen/tooltip 共发布 1 个版本,首次发布于 2015/08/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.2latest2015/08/0911 年前

关于 @fengyuanchen/tooltip 的常见问题

@fengyuanchen/tooltip 是什么?

A simple jQuery tooltip plugin.注意:该包已被作者标记为弃用——No longer maintainted.

如何安装 @fengyuanchen/tooltip?

在项目目录运行 npm install @fengyuanchen/tooltip,或使用 pnpm add / yarn add / bun add。

@fengyuanchen/tooltip 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fengyuanchen__tooltip 是否存在。

@fengyuanchen/tooltip 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fengyuanchen/tooltip 可以商用吗?

@fengyuanchen/tooltip 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fengyuanchen/tooltip 的下载量有多少?

根据 npm 官方下载统计,@fengyuanchen/tooltip 在 2026/10/15 – 2026/11/13 这 30 天内被下载 22,128 次,日均约 738 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fengyuanchen/tooltip 还在维护吗?

最新版本 0.0.2 发布于 2015/08/09(11 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2015/08/09。作者已将其标记为弃用,新项目建议寻找替代方案。