Help Center

Adding Custom Tooltips Within JetElement’s Table, Tabs, and Accordion Widgets

Learn how to add custom tooltips inside widgets, blocks, and tables, where you can't do it with the JetTricks plugin, as it adds them to widgets, not inline.

Before you start, check the tutorial requirements:

Use HTML Attribute (for Desktops Only)

Using an HTML attribute is the simplest way to add WordPress tooltips; however, in this case, the tooltip will be visible on desktops on hover, but not on mobiles.

In this case, we add the Tabs widget to the page, unroll the Items settings, and insert the following HTML directly into the Label field.

<i title="Tooltip text" class="fas fa-info-circle"></i>

where the “Tooltip text” is the text to be displayed in the corresponding tab.

In this case, the text in the Label field looks as follows:

<i title="Just read it!" class="fas fa-info-circle"></i>
the tooltip added to the tabs widget on the front end

Add HTML (for Desktops and Mobiles) 

The cases described herein display the needed tooltip texts on mobiles and on desktops while hovering or clicking.

Things to know

For better UX, it is recommended to add an info icon or short hint to indicate the presence of a tooltip. On desktop, it appears on hover, but on mobiles, users need to tap, so there should be a clear visual cue that the element is interactive.

Add inline HTML to a widget title

The following HTML element can be added to the Title element of the Tabs widget or the Classic Accordion widget.

the code for displaying on mobiles added to the tabs widget
Tab#1: &nbsp; <span class="tooltip" data-tip="Your tooltip text here">   <i class="fas fa-info-circle"></i> </span>

where:

  • Tab#1 一 the name of the particular tab;
  • &nbsp; 一 the space sign, can be inserted as many times as needed; 
  • Your tooltip text here” 一 the tooltip text to be displayed;
  • <i class=”fas fa-info-circle”></i> 一 a specific “Info” icon from the Font Awesome4.

On the front end, the widget displays the “Your tooltip text here” text after hovering.

the tooltip for displaying on mobiles and desktops
Things to know

To enable Font Awesome 4 support to make sure all previously selected Font Awesome 4 icons are displayed correctly while using the Font Awesome 5 library, move to the WordPress Dashboard > Elementor Editor > Settings > Advanced tab and select the "Yes" option in the Load Font Awesome 4 Support drop-down menu.

If you don’t want to display icons, you can use any text sign instead. You can also place the icon or text slightly above the line by wrapping it in a <sup></sup> tag as follows:

Tab #1 &nbsp; <span class="tooltip" data-tip="Your tooltip text here"> <sup><i class="fas fa-info-circle"></i></sup> </span>

Add СSS and JavaScript 

For this method, you will need to insert custom CSS and JavaScript either by using Elementor Pro or another plugin for custom snippets.

We will show a method that uses Elementor Pro.

First, go ahead to the WordPress Dashboard > Elementor > Editor > Custom Elements > Code tab and insert the code into the corresponding field.

the edit code window

Once completed, press the “Update” field to save the snippet.

If you have no Elementor Pro, you can use any custom snippet plugin, for example, Post Snippets (since it supports JavaScript in the free version), and insert JavaScript and CSS separately.

Things to know

If you add a tooltip to a table row in the Table widget of the JetElements plugin, insert the following CSS as well:

.jet-table td,

.jet-table tr,

.jet-table tbody,

.jet-table {

overflow: visible!important;

}

If there are elements that can overlap this tooltip because they overlap parent containers, then you should either change the Z-index of the parent containers, or use the following approach 一 it will always be on top of other elements, but slightly more complex. First, insert these CSS and JavaScript:

<style>

#tooltip-global {

  position: fixed;

  transform: translate(-50%, -100%);

  z-index: 999999;

  background: #222;

  color: #fff;

  font-size: 12px;

  padding: 6px 10px;

  border-radius: 4px;

  white-space: nowrap;

  pointer-events: none;

  display: none;

}

</style>

<!-- JS (mobile tap) -->

<script>

(function(){

  let tooltip;

  function getTooltip() {

    if (!tooltip) {

      tooltip = document.createElement('div');

      tooltip.style.position = 'fixed';

      tooltip.style.zIndex = '999999';

      tooltip.style.background = '#222';

      tooltip.style.color = '#fff';

      tooltip.style.padding = '6px 10px';

      tooltip.style.borderRadius = '4px';

      tooltip.style.fontSize = '12px';

      tooltip.style.whiteSpace = 'nowrap';

      tooltip.style.pointerEvents = 'none';

      tooltip.style.display = 'none';

      document.body.appendChild(tooltip);

    }

    return tooltip;

  }

  document.addEventListener('mousemove', function(e){

    const el = e.target.closest('.tooltip');

    const t = getTooltip();

    if (el) {

      t.textContent = el.getAttribute('data-tip');

const rect = el.getBoundingClientRect();

t.style.left = (rect.left + rect.width / 2) + 'px';

t.style.top = (rect.top - 3) + 'px';

t.style.transform = 'translate(-50%, -100%)';

      t.style.display = 'block';

    } else {

      t.style.display = 'none';

    }

  });

})();

</script>

Add the following HTML directly to the Table widget from the JetElements plugin in the Text field of the heading:

Tab #1 &nbsp; <span class="tooltip" data-tip="Your tooltip text here">   <i class="fas fa-info-circle"></i> </span>
the code added to the table widget

Then, move to the front end and check the result.

the code added to the table widget on the front end

You can use this method for any inline element. For block elements (templates, widgets), tooltips can be easily added using the JetTricks plugin. It allows you to add flexible tooltips, control their positioning, and animation. 

Add the Tooltip to a Form

The JetFormBuilder plugin allows inserting text to be shown in the field, and in this way, it covers the tooltip functionality. To add the needed text into a particular field, move to the particular field’s setting block, unroll the Advanced settings, and insert the needed text into the PLACEHOLDER field.

the form placeholder field

However, if you need to add the tooltip, use the same method described above and add the HTML to a LABEL field.

FAQ

What content can I display inside a custom tooltip?

You can add text, images, icons, and links.

What option can be styled while customizing the tooltips?

To customize the tooltip, unroll the Style tab and configure the tooltip’s colors, typography, spacing, borders, and more.

Is it possible to add tooltips to other widgets?

No, currently this functionality is unavailable.

Can I add tooltips to one table cell only, or add different tooltips to different cells?

Yes, both are possible.

Can I apply different styling to different tooltips configured in the same widget?

No, currently this functionality is unavailable.

That’s it. Now you know how to add a custom tooltip to an inline element inside a table, tab, or form label on your WordPress site.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 30K+ Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.