Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tooltipster-htmltitle

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tooltipster-htmltitle

A Tooltipster plugin that lets you easily point out an HTML element to serve as tooltip content.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

tooltipster-htmlTitle

A Tooltipster plugin that lets you easily point out an HTML element to serve as tooltip content. MIT license.

This plugin doesn't add much to Tooltipster, it's rather meant for beginners who are not comfortable with manipulating their DOM with jQuery and who need the most simple instructions.

Installation

Include the plugin file in your page AFTER the Tooltipster bundle file.

<html>
    <head>
        ...
        <script type="text/javascript" src="tooltipster/dist/js/tooltipster.bundle.min.js"></script>
        <script type="text/javascript" src="tooltipster-htmlTitle/tooltipster-htmlTitle.min.js"></script>
    </head>
</html>

Usage

You can now set a data-htmltitle attribute on your origins to point out which HTML element in the page should be used as content for the tooltip.

<span class="tooltip" data-htmltitle="#tooltip_content">This text has a tooltip when you hover over it</span>

<span id="tooltip_content"><img src="image.jpg" /> <b>This is the content of my tooltip!</b></span>

If the selector you provide in the attribute matches several elements, only the first one will be used.

If you have two tooltips that have the same data-htmltitle (that is to say, want to both use a single HTML element), don't forget to set the contentCloning option to true when you initialize your tooltips.

Full example

I suggest you set up your page like this:

HTML:

<span class="tooltip" data-htmltitle="#tooltip_fruit">Cherries</span>
<span class="tooltip" data-htmltitle="#tooltip_fruit">Strawberries</span>
<span class="tooltip" data-htmltitle="#tooltip_vegetable">Carrots</span>

<div id="templates">
    <span id="tooltip_fruit"><img src="fruit.jpg" /> <b>These are fruit!</b></span>
    <span id="tooltip_vegetable"><img src="vegetable.jpg" /> <b>These are vegetables!</b></span>
</div>

CSS:

#templates {
    display: none;
}

Javascript:

$('.tooltip').tooltipster({
    contentCloning: true
)};

Options

htmlTitleScope By default, the plugin will search in the page for an element that matches your selector. If you wish to search in other scope, for example if you maintain your templates somewhere else, you may provide it here.

Keywords

FAQs

Package last updated on 16 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc