Skitterm
Skitterm

Reputation: 4595

Inspect hovered element in Chrome?

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?

Upvotes: 210

Views: 174847

Answers (29)

dwjohnston
dwjohnston

Reputation: 11900

F8 will pause debugging.

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.

Upvotes: 248

Razor
Razor

Reputation: 11

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

Upvotes: 1

Mijo
Mijo

Reputation: 611

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.

Upvotes: 0

hasti usefi
hasti usefi

Reputation: 1

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.

Upvotes: 0

chaendler
chaendler

Reputation: 91

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.

Upvotes: 4

mikemaccana
mikemaccana

Reputation: 123610

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.

Upvotes: 41

K Name
K Name

Reputation: 1

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

Upvotes: 0

Gayan Chinthaka
Gayan Chinthaka

Reputation: 569

  1. appear the hovered item by over mouse
  2. windows --> Ctrl + shift + c || Mac --> Command + Option + C

Upvotes: 2

Shabbir Vaghela
Shabbir Vaghela

Reputation: 244

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

window.onkeydown = () => { debugger }

Upvotes: 5

sandeep
sandeep

Reputation: 61

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

Upvotes: 6

ansavchenco
ansavchenco

Reputation: 685

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.

Upvotes: 6

Okau123
Okau123

Reputation: 1

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.

Upvotes: 0

Muhammad Awais
Muhammad Awais

Reputation: 365

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

Upvotes: 0

Catalin
Catalin

Reputation: 125

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

Upvotes: 11

Kaspars Siricenko
Kaspars Siricenko

Reputation: 15

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

Upvotes: -3

Ali Kleit
Ali Kleit

Reputation: 3649

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..)

Upvotes: 114

Parvez Ahmed
Parvez Ahmed

Reputation: 69

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.

Upvotes: 6

Ricardo Magalhães
Ricardo Magalhães

Reputation: 227

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!

Upvotes: 2

TobyLL
TobyLL

Reputation: 2306

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>

Upvotes: 39

Rajan
Rajan

Reputation: 157

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

Upvotes: 3

clhenrick
clhenrick

Reputation: 1137

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.

Upvotes: 7

Adam Grant
Adam Grant

Reputation: 13125

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')

Upvotes: 70

Nolan Lindeke
Nolan Lindeke

Reputation: 41

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.

Upvotes: 0

user1806949
user1806949

Reputation: 81

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.

Upvotes: 0

John Rix
John Rix

Reputation: 6703

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.

Upvotes: -1

joeyyang
joeyyang

Reputation: 1183

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.

Upvotes: 95

lxg
lxg

Reputation: 13127

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.

Upvotes: 3

philip
philip

Reputation: 206

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.

Upvotes: 0

Justin Chmura
Justin Chmura

Reputation: 2037

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.

Upvotes: 118

Related Questions