Code Monkey home page Code Monkey logo

tooltip's Introduction

Tooltip

A simple JavaScript tooltip library.

Usage

You can add a tooltip to any element you like. For example, we could add a tooltip to any element with a tooltip class.

Tooltip.new('.tooltip');

By default it will assume you have a data-title attribute that will be used for the tooltips contents.

<span class="tooltip" data-title="Hello, World">This will have a tooltip!</span>

Options

You can pass options to the new function as the second argument. The options are as follows.

width

The maximum width of the tooltip container.

offset

The offset of the tooltip from the element it is attached too. Can be a positive or negative number.

position

The position of the tooltip. Available options are: top, topLeft, topRight, right, left, bottomRight, bottomLeft, bottom

attribute

The attribute that contains the tooltip contents. Defaults to data-title.

Example

Here is an example using the available options.

Tooltip.new('.tooltip', {
	width: 400,
	offset: 2,
	position: 'bottomLeft',
	attribute: 'data-tooltip'
});

<span class="tooltip" data-tooltip="Hello, World">This will have a tooltip!</span>

Compatibility

Should work in all modern browsers. Not tested in IE although it should work in IE10+.

License

Released under the BSD 2-Clause License.

tooltip's People

Contributors

jasonlewis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ncou

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.