123

I am trying to view, through Chrome's developer tools, how tooltips are structured on a site. However, even when I am hovered over the item, when I "inspect element", nothing shows for the tooltip in the html. I know I can set the Style to :hover, but I still can't see the html or css of the tooltip.

Any ideas?

nbro
  • 12,226
  • 19
  • 85
  • 163
Skitterm
  • 3,548
  • 7
  • 33
  • 52

24 Answers24

137

F8 will pause debugging.

On Mac, you may need to have the 'Sources' tab of the developer tools open.

Mouse over the tooltip, and press F8 while it is displayed.

You can now use the inspector to look at the CSS.

dwjohnston
  • 7,389
  • 20
  • 81
  • 147
93

I actually found a trick to do that with the Twitter Bootstrap tooltips. If you open the dev tools (F12) on another monitor, then hover over the element to bring up the tooltip, right click as if you were to select 'Inspect Element'. Leaving that context menu open, move the focus over to the dev tools. The html for the tooltip should show up next to the element its a tooltip for in the HTML. Then you can look at it as if it were another element. If you go back to Chrome the HTML disappears so just something to be aware of.

Kind of a weird way but it worked for me so I figured I would share it.

mikemaccana
  • 81,787
  • 73
  • 317
  • 396
Justin Chmura
  • 1,761
  • 14
  • 17
  • 14
    Well yes, but not on Mac. – actimel Jan 27 '15 at 08:48
  • 2
    - Step 1: Inspect element that generates the tooltip to bring up the Chrome Dev tools. - Step 2: while hovering over the element, your tooltip will appear. Without leaving the element, open a new window (Command-N on Mac, Ctrl-N elsewhere) - Step 3: Drag the new window below the old window, so you can still see the tooltip, then move your cursor into the Element inspector. - Step 4: Scroll to the bottom, where your tooltip is appended to the DOM. Click the element to see its styling. – pgblu Jun 10 '15 at 20:49
  • 2
    P.S. this does not work for tooltips which are generated via Javascript from the element's own title attribute, as for example happens on SO. Those tooltips use a default styling. – pgblu Jun 10 '15 at 21:03
  • This helped me for tooltips in Kendo – k29 Dec 13 '18 at 14:11
  • Used successfully with Bootstrap 3 – lrkwz Feb 27 '19 at 10:31
  • Mozilla Firefox seems to allow inspecting the tooltip by default – dev27 Mar 04 '20 at 17:00
  • 4
    The trick: First go to source tab. Then you can pause Javascript with F8 button. The pause key is there with shortcut of F8 / Ctrl+\ (The answer from @Rajan on this page) – rostamiani Apr 29 '20 at 04:25
85

This solution works without any extra code.

Hit command-option-j to open the console. Click the window-looking button on the top right corner of the console to open the console in a different window.

Then, in the Chrome window, hover over the element that triggers the popover, hit command-` however many times you need to focus on the console, then type debugger. That'll freeze the page, then you can inspect the element in the Elements tab.

joeyyang
  • 1,054
  • 7
  • 9
  • 6
    This answer is really nice. Minimal code, no jQuery or dual monitor setup. – uKolka Oct 20 '14 at 20:16
  • 1
    It worked! Initially due to some misconfiguration, I was seeing the default HTML tooltips and not the Bootstrap tooltips. After fixing that issue, your solution worked. Thanks. – DFB Aug 30 '15 at 05:17
  • 2
    Additionally if you loose focus while writing `debugger` to console, you can press `alt+tab` while hovering over the element. It worked for Chromium apps on Windows. – Orcun Feb 07 '19 at 11:29
  • 1
    This was a great answer! – Nobita Mar 07 '19 at 10:05
  • Chrome DevTools Keyboard Shortcuts page says it is a control+` instead of command+` to focus back on the console. Maybe it changed. – rinat.io Oct 18 '19 at 14:23
  • How to run the debugger again after pausing? – testing Feb 17 '20 at 09:03
  • yes! opening the tools in flyout window (not a sub-window of the main browser) allowed me to achieve this! – samneric May 02 '20 at 17:56
64

You would just need to force the tooltip to show as such

$('.myelement').tooltip('open');

Now the tooltip will show regardless of hovering state.

Scroll down near the bottom of the DOM where you should see the markup.

Update see cneuro's comment for Bootstrap 3.

$('.myelement').tooltip('show');

Update see Marko Grešak's answer for Chrome and apparently Safari as well, $0 can be used as a shortcut for the currently selected element. This appears to work in Safari as well.

$($0).tooltip('show')
Adam Grant
  • 10,123
  • 9
  • 51
  • 65
  • 1
    $('.myelement').tooltip('open') is what worked for me. – tekumara Oct 27 '14 at 13:20
  • 7
    As of Bootstrap 3, this is now `.tooltip('show')` http://getbootstrap.com/javascript/#tooltips-methods – cneuro Apr 26 '15 at 16:36
  • 3
    In Chrome, the currently selected element can be accessed as `$0` in the console. Therefore you can select the element which triggers a tooltip and run `$($0).tooltip('show')`. – Marko Gresak Mar 16 '17 at 01:21
36

Click f12 go to the console tab and add the following:

setTimeout(()=> {debugger},5000)

This will give you 5 seconds to do whatever you want and it will break at 5 seconds. Then you can inspect the target element

(ex. hover the element and wait 5 seconds then inspect..)

Ali Kleit
  • 1,677
  • 2
  • 15
  • 26
28

For me, the accepted answer didn't work: clicking in DevTools immediately closed the ToolTip.

However, I found https://superuser.com/questions/249050/chrome-keyboard-shortcut-to-pause-script-execution which helped me:

  1. In the console:, Run:
    const F12 = 123
    window.addEventListener('keydown', function(event) { 
      if (event.keyCode === F12 ) {
        debugger; 
      }
    });
  1. Highlight element with inspector

  2. Hit F12

You can now inspect the element, with JavaScript paused so the DOM won't change.

mikemaccana
  • 81,787
  • 73
  • 317
  • 396
  • 1
    Clever ! Exactly what I was looking for. Thank you :) Although it did not work with F12 with my setup for some reason, so I used keyCode == 13 and pressed ENTER. – Jeremy F. Feb 01 '16 at 16:30
  • 2
    great solution! i would suggest to save this useful snippet in the SOURCE -> SNIPPETS area of chrome so you can execute it with just a double click ;) – Magico Jun 01 '16 at 22:19
  • 1
    Great solution. Very clever. – Charlie Dalsass Dec 03 '18 at 21:44
16

Single window answer, with no coding

None of the other answers are quite right, or have enough detail, so here's my attempt.

  • Open Chrome's DevTools using F12/Ctrl+Shift+I (Windows/Linux) or Command+Option+I (Mac).
  • Select the Sources tab in the DevTools window.
  • Using the mouse, hover over the element you want to inspect, to make the tooltip visible.
  • Press F8 (Windows/Linux/Mac) to pause script execution. The main window will grey out, and a "Paused in debugger" popup will appear.
  • In the DevTools window, select the Elements tab
  • For Bootstrap tooltips, the tooltip will appear as the last <div> in the <body>
TobyLL
  • 1,748
  • 2
  • 13
  • 20
5

No code solution for JS activated tooltips:

With Chrome's devtools inspect the containing / parent element of the tooltip. In the "elements" tab, right click on that container DOM element then choose "break on" > "subtree modifications". The next time you hover over the part of the DOM the tooltip is housed in, the JS code will be paused allowing you to inspect the contents of the tooltip.

clhenrick
  • 748
  • 6
  • 12
5

Follow these steps

  1. Open Inspect window in chrome.

  2. Place the mouse over the tooltip.

  3. Press F8

    JS execution will be paused and then you can inspect the tooltip.

  4. Press F8 again to start execution and F10 to debug.

RobC
  • 16,905
  • 14
  • 51
  • 62
Parvez Ahmed
  • 59
  • 1
  • 1
4

it is so simple to edit these tooltips.

Step 1: Inspect the element that has the tooltip. Make sure it is highlighted with blue in devtools.

Step 2: right-click on the element (in devtools part) and select: attribute modifications, under Break on enter image description here

Step 3: Hover over the inspected element and a gray overlay will appear over the site with a small text: Paused in debugger

enter image description here

at the top of your screen

Step 4: Click on the blue arrow until the hover state is selected.

Step 5: Inspect and edit the tooltip

Community
  • 1
  • 1
Catalin
  • 55
  • 7
3

1)Open the Inspect window by clicking F12

2)Go to source tab(next to console)

3)Now hover on element to be inspected and keep your mouse over there.

4)Using keyboard(Tab or shift+tab) to move the control to pause button or F8Refer the image

5)When keyboard focus is on Play button. Hit enter. Your hover element will be freezed you can do anything now

Rajan
  • 23
  • 8
2

Here’s a simple solution: If you have dynamic tooltips, you can make them “persistent” by (temporarily) changing the trigger event to click. This will have the effect that the tooltip only disappears on a click-out:

$('body').tooltip({
    selector: "[data-toggle='tooltip']",
    trigger: "click"
});

This way, it can be easily inspected with FF’s or Chrome’s debugging tools.

lxg
  • 10,238
  • 11
  • 37
  • 60
2

Here is how I did it on Mac:

  1. Hover over the element that has a tooltip with chrome devtools opened.
  2. Wait for the tooltip to appear.
  3. Open devtools command palette with a keyboard shortcut. Cmd+Shift+P worked for me.
  4. Type in Disable JavaScript and press Enter

This will prevent from fading all the tooltips that utilize JavaScript.

savchenkoto
  • 151
  • 1
  • 10
2

Hover over the element, press F8 for little longer, it will pause script execution.

sandeep
  • 21
  • 1
1

The dev tools provides a way to inspect a hovered element like a tooltip.

1 - Open the dev tools using F12.

2 - Select "Elements" tab.

3 - Select the parent element that contains the tooltip.

4 - Click on "..." (on the line of the parent element) and after select "Break on"/"subtree modifications" (see image below)

Set a Break on parent element

5 - Finally go back to application and make the Tooltip shows up. It should block the execution after the Tooltip gets visible

Hope it can be useful for someone!

0

I had problems with this so I went to the documentation and inspected the tooltip that is already rendered on the page. That helped me see the dom structure of the tooltip and edit it accordingly.

philip
  • 206
  • 1
  • 10
0

In Chome on Linux this can be achieved for JS generated tooltips such as those for references on WikiPedia by doing the following:

As stated above, open the dev tools using F12. Open them in another window. Highlight the tooltip and click Ctrl-Shift-C (The HTML Inspector). As you move over the tip, the dev window will show the appropriate section.

If you need to keep the tip open when you mouse off it, to be able to inspect it in the other window more thoroughly, then right click on the tooltip and leave the context menu up, and click on the the dev tools window. In this scenario it leaves the tip up in the wikipedia window.

To a degree it also works with bootstrap tips.

user1806949
  • 81
  • 1
  • 3
0

For some reason the answers provided here weren't working for me on Windows. I was able to inspect the tooltip by opening the dev tools, then hovering over the element that brings up the tooltip, then right clicking on that element (not the tooltip). Then, move the cursor over into the inspector panel and scroll down to the bottom. The tooltip element should still be there.

0

Another Solution I found for this problem. Through Mobile or Tablet view in Chrome press Crt + Shift + M in Chrome Dev tools for Mobile view in Chrome. Click(Tap) on ToolTip div and you can inspect it with Right Click on tooltip

HERAwais
  • 159
  • 4
  • 16
0

Hit command-option-j to open the console. Click the window-looking button on the top right corner of the console to open the console in a different window.

Then, in the Chrome window, hover over the element that triggers the popover, hit command- however many times you need to focus on the console, then type debugger. That'll freeze the page; then you can inspect the element in the Elements tab.

UmFraWJ1bCBJc2xhbQ
  • 4,101
  • 6
  • 24
  • 41
0

just hit one line script in console and press any key to enter in debug mode.

window.onkeydown = () => { debugger }
0
  1. appear the hovered item by over mouse
  2. windows --> Ctrl + shift + c || Mac --> Command + Option + C
Adrian Mole
  • 30,672
  • 69
  • 32
  • 52
-1

Worth noting that toggling the :hover state from within the dev tools only has an impact if the hint text is enabled via CSS :hover rules in the first place. The toggle only applies the hover state to the element for rendering purposes, but does not trigger a corresponding JavaScript mouseover event.

Many frameworks such as AngularJS dynamically attach tooltip HTML to the bottom of the document body via JavaScript when a target element is hovered, so any amount of hovering and inspecting the target element won't help.

@joeyyang's answer worked very well for me in this scenario.

John Rix
  • 4,931
  • 3
  • 35
  • 39
-2

One of the easiest ways I found is:

  1. Open Chrome dev tools on the side

  2. Hover over element

  3. Right-click

  4. Click on dev tools

  5. Now you can inspect and change styles