183

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
  • 15,395
  • 32
  • 113
  • 196
Skitterm
  • 4,257
  • 7
  • 38
  • 54

29 Answers29

211

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
  • 11,163
  • 32
  • 99
  • 194
  • 22
    I like how in Stackoverflow, as long as you keep scrolling down you'll find that really good answer that is far and beyond better than the rest. This is simple and easy without extra scripts. – Alexander Dixon Jan 06 '17 at 20:06
  • 4
    F8 didn't work for me for some reason, but pause is also bound to ctrl-\ – Bryan Larsen Mar 03 '17 at 13:16
  • 1
    Neither F8 nor AltGr-RCtrl-ß on my German keyboard layout pauses the debugger. – testing Feb 17 '20 at 08:49
  • It isn't just Mac where you may need to give the focus to the Sources tab. I made the original edit because this affected the running of code in Electron. I suspect this focus is needed anytime you have any source files open at all in that tab. – Paul F. Wood Oct 11 '20 at 12:57
  • Note that this doesn't work if focus is on the Inspect Element find search box (among other things) when you hit F8 – philipnye Nov 20 '20 at 09:45
  • 3
    Didn't work for me. On a Mac in Chrome – ineedtoknow Dec 06 '21 at 22:17
  • Can confirm that on Windows this only worked if I had the Sources tab selected in the Dev Tools window before I hovered over the element on the web page and hit F8. If the Elements tab is selected, hitting F8 does nothing. – Philip Stratford Mar 16 '23 at 21:15
109

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
  • 110,530
  • 99
  • 389
  • 494
Justin Chmura
  • 1,939
  • 1
  • 15
  • 17
  • 15
    Well yes, but not on Mac. – actimel Jan 27 '15 at 08:48
  • 3
    - 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
94

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,164
  • 8
  • 10
  • 7
    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
  • This works great. Though for me when dev tools window focused I could not type because focus was on some button within the window. Had to press multiple tabs to get to the console area. – abhishekkannojia Sep 03 '21 at 06:29
88

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
  • 3,069
  • 2
  • 23
  • 39
  • 1
    Works in Electron, too. – xmedeko Oct 15 '19 at 08:51
  • 4
    Thanks, this was the only solution that worked for me on Mac Chrome (Bootstrap 4) – Franz May 11 '21 at 23:20
  • This kinda seems like a copy of my answer from 2013 (except you have to wait rather than just pressing a keyboard shortcut when you want to pause the DOM). – mikemaccana Aug 10 '22 at 14:01
  • This works in firefox! – Akaisteph7 Nov 02 '22 at 17:05
  • @mikemaccana the main difference I see with this one is that at least in more recent versions of Chrome, for items that disappear when focus is lost, this one still works. (Previously I agree, hitting the key or hitting pause was stopping everything immediately.) I was also able to use this solution when I could not inspect an ephemeral element because its CSS was broken and it was not visible or clickable on screen (i.e. couldn't inspect). – Chris Chiasson Feb 03 '23 at 18:39
  • Such a smart response, it's impressive. Thanks – codewonders Jul 06 '23 at 19:27
  • brilliant answer. – TimeTraveler Aug 12 '23 at 10:54
68

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
  • 12,477
  • 10
  • 58
  • 65
  • 1
    $('.myelement').tooltip('open') is what worked for me. – tekumara Oct 27 '14 at 13:20
  • 8
    As of Bootstrap 3, this is now `.tooltip('show')` http://getbootstrap.com/javascript/#tooltips-methods – cneuro Apr 26 '15 at 16:36
  • 4
    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
  • I know that jQuery used to be the rage couple of years ago and that this answer is 1- years old but I can't help but ask why did people think it was a good idea to use jQuery for everything? Did query selectors not exist 10 years ago? – Michal Feb 21 '23 at 19:35
36

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
  • 110,530
  • 99
  • 389
  • 494
  • 3
    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
36

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
  • 2,098
  • 2
  • 17
  • 23
8

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
  • 95
  • 2
  • 7
7

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
  • 798
  • 6
  • 13
6

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
  • 22,977
  • 20
  • 73
  • 80
Parvez Ahmed
  • 69
  • 1
  • 1
6

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.

ansavchenco
  • 535
  • 6
  • 14
5

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

sandeep
  • 51
  • 1
  • 2
  • A little more detail perhaps? – 10 Rep Feb 03 '21 at 22:28
  • basically if you press F8 while the inspector window is open, it will pause execution, with frameworks like Angular, there is always something running in the background that can pause. This will prevent the script running that closes the tooltip and removes the element, thus, allowing you to inspect it in the elements panel – Ben Taliadoros Jul 01 '22 at 14:44
3

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
  • 12,375
  • 12
  • 51
  • 73
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
  • 95
  • 12
3

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

window.onkeydown = () => { debugger }
Shabbir Vaghela
  • 224
  • 2
  • 8
  • Just a quick note on this: make 100% sure to remove this before releasing - it slows your app down just having one debugger statement anywhere in it (it hurts the JIT compiler IIRC) – Andrew Faulkner Jun 14 '21 at 15:48
2
  1. appear the hovered item by over mouse
  2. windows --> Ctrl + shift + c || Mac --> Command + Option + C
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Gayan Chinthaka
  • 521
  • 6
  • 5
2

Land in this post for answers and find eventually a way to do it. Inspect the parent element of tooltip and set break on subtree change devtool brean on subtree change and hover your mouse on element and click F8 till the tooltip appear. You can have your tooltip and check the styling.

chaendler
  • 61
  • 2
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!

1

Chrome dev tools. In elements right click on the button you want to show the tooltip or hover element. There is an option to force whatever state you want. Go to For State :hover

Razor
  • 11
  • 1
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
  • 216
  • 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
  • 357
  • 5
  • 21
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.

UkFLSUI
  • 5,509
  • 6
  • 32
  • 47
0

I found a good way I was struggling with this : • Open Elements Tab • Inspect an element on the page , should be close to the element that you are trying to inspect • Hover over the tooltip • While the dev/Elements tab is open Hit Ctrl F to move the focus to Text area in element tab where it Says Find by string , selector , or Xpath • use the keyboard key to navigate up/down the elements till you will get to the elements that you are looking for , dont touch your mouse

K Name
  • 1
  • 1
0

some tooltips disappeared when we open the inspect part on hover mode, sometimes they don't disappear when change responsive tab (active or inactive button). then you can right click and get inspect from it.so easily.

0

I once had issue with a JS generated tooltip. I paused the chrome debugger using f8, however, the element was unreachable, as it was a tooltip for a Qlik Sense map, so a lot of items are appearing under it. I have done a simple workaround. While the sources are displayed on the right, I started right clicking on each div and deleting it from the inspector, till I found the div. Hope this helps.

Mijo
  • 611
  • 8
  • 10
-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
  • 6,271
  • 5
  • 40
  • 46
-3

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