class="js-tooltip"
into a span class="your-prefix-class-container"
, when you activate one, it inserts a dialog element just after the clicked element (in the container), puts the focus into it and traps focus in the dialog tooltip. When you exit it, the focus is given back to the element that opened it.
10 |
11 | For mouse users, they can click outside the dialog tooltip to close it.
12 |
13 | If you never activate a dialog tooltip, it won’t be anywhere in the code.
14 |
15 | ## Options and attributes
16 |
17 | Simply put class="js-tooltip"
on a button to activate the script.
18 |
19 | - Attribute data-tooltip-prefix-class
: the prefix to all style classes of the dialog tooltip.
20 | - Attribute data-tooltip-text
: the text of your dialog tooltip (will be put into a p
tag).
21 | - Attribute data-tooltip-content-id
: the id
of (hidden) content in your page that will be put into your dialog tooltip.
22 | - Attribute data-tooltip-title
: the main title of the dialog tooltip.
23 | - Attribute data-tooltip-close-text
: the text of the close button in your dialog tooltip.
24 | - Attribute data-tooltip-close-title
: the title
attribute of the close button in your dialog tooltip.
25 | - Attribute data-tooltip-close-img
: a path to a valid image for the close button.
26 |
27 | Another feature: when you click on a button that launches a modal tooltip, the class is-active
is added to this button.
28 |
29 | Enjoy.
30 |
31 |