"Inspect" a hover element?

Google ChromeBrowserHoverGoogle Chrome-DevtoolsInspect

Google Chrome Problem Overview


Note: I've read similar threads, but none quite my issue - I can right click on it fine, it just then disappears.

I find "Inspect Element" an invaluable tool in Chrome, however my latest foray as I learn the wizardly ways many of you already possess saw me creating a sub-menu for an element on my nav bar, which pops up below on hover of it's parent item.

The popup(or down) isn't quite styled how I'd like, so I right-click > inspect element to see what's coming from where exactly, and get a better idea of how to achieve my desired effect.

However, as soon as I move my mouse away from the menu, it's gone.

So I can't select different elements in the inspection pane, and see which area is highlighted at the same time.

Is there a way around this, without changing the menu so that it stays "popped up" once activated?

Google Chrome Solutions


Solution 1 - Google Chrome

If the hover is triggered by JS, just pause script execution via the keyboard. This is a much simpler way of freezing the DOM than the other answers suggest.

Here's how you do it in Chrome. I'm sure Firefox has an equivalent procedure:

  1. Open up Developer Tools and go to Sources.

  2. Note the shortcut to pause script execution—F8.

    Pause script execution

  3. Interact with the UI to get the element to appear.

  4. Hit F8.

  5. Now you can move your mouse around, inspect the DOM, whatever. The element will stay there.

Solution 2 - Google Chrome

If the hover effect is given with CSS then yes, I normally use two options to get this:

One, to see the hover effect when the mouse leave the hover area:
Open the inspector in docked window and increase the width until reach your HTML element, then right click and the popup menu must be over the inspector zone... then when you move the mouse over the inspector view, the hover effect keep activated in the document.

enter image description here

Two, to keep the hover effect even if the mouse is not over the HTML element, open the inspector, go to Styles TAB and click in the upper right icon that says Toggle Element State...(dotted rectangle with an arrow) There you can manually activate the Hover Event (among others) with the checkbox provided.

enter image description here

If it's not clear at all, let me know and I can add a few screenshots. Edited: screenshot added.

And finally and as I say at the begining, I only be able to do this if the hover is set with CSS:HOVER... when you control the hover state with jQuery.onMouseOver for example, only works (sometimes), the method One.

Hope it helps.

Solution 3 - Google Chrome

What worked for me is selecting the specific a tag I wanted to inspect and do this:

enter image description here

After doing the above, I would again normally select that a tag then the dropdown will automatically stay as-is even when I mouseover to other places like Inspect Element, etc.

You can just refresh the browser when doing inspecting the menu dropdown elements to go back to normal state.

Hope this helps. :)

Solution 4 - Google Chrome

You can also do this in the javascript console:

$('#foo').trigger('mouseover');

An that will "freeze" the element in the "hover" state.

Solution 5 - Google Chrome

Here's how I do it with no CSS changes or JS pausing in Chrome (I am on a Mac and do not have a PC in front of me if you are running on Win):

  1. have your developer console open.
  2. do not enable the hover inspection tool yet, but instead open up your desired sub menu by moving your mouse over it.
  3. hit Command+Shift+C (Mac) or Ctrl+Shift+C (Win/Linux)

now the hover inspection tool will apply to the elements you have opened in your sub-nav.

Solution 6 - Google Chrome

Not sure if it was present in previous browser revisions, but I just found out this extremely simple method.

Open the inspector in chrome or Firefox, right click on the element you are interested in, and select the appropriate option (in this case: hover). This will trigger the associated CSS.

Opening the menu in chromium Opening the same menu in Firefox

Screenshots from Firefox 55 and chromium 61.

Solution 7 - Google Chrome

I needed to do this, but the element I was trying to inspect was added and removed dynamically based on hover state of another element. My solution is similar to this one, but that didn't quite work for me.

So here's what I did:

  1. Add simple script to enter debugger mode upon mouseover of the element that triggers the hover event you're concerned about.
$(document).on('mouseover', '[your-hover-element-selector]', function(e) {
  debugger;
});
  1. Then, with the dev console open in Chrome, hover over your element, and you will enter debugger mode. Navigate over to the sources section of the dev tools, and click the "Resume script execution" button (the blue play-like button below).

enter image description here

Once you do that, your DOM will be paused in the hover state, and you can use the element inspector to inspect all the elements as they exist in that state.

Solution 8 - Google Chrome

I found a very simple way to do this if for some reason you have problems with script pausing:

  1. Open Dev Tools on "inspect"-tab.
  2. Hover to make the pop-up appear.
  3. Right-click on the desired element in your pop-up and press 'Q' (in Firefox) to inspect that element.
  4. Use keyboard to navigate:
    • Arrow Up/Down: Move between elements
    • Arrow Left/Right: Collapse/Expand
    • Tab/Shift+Tab: Move between inspector and CSS rules and inside CSS Rules
    • Enter: Edit CSS Rule

Solution 9 - Google Chrome

Excellent stuff!

Thank you to gmo for that advice. I did not know about those attribute settings massively helpful.

As a small revision to the wording I would explain that process as follows:

  • Right Click on the element you would like to style

    • Open 'Inspect' tool

    • On right hand side, navigate to the small Styles tab

    • Found above CSS stylesheet contents

    • Select the .hov option - This will give you all the settings available for the selected HTML element

    • Click and Change all options to be inactive

  • Now Select the state that you would like to tweak - On activation of any of these, your Stylesheet will jump you directly to those settings:

Styles - Tweaking Filters - Interactive elements

This information was a lifesaver for me, cannot believe I have just heard about it!

Solution 10 - Google Chrome

  1. Open Inspect element

enter image description here

  1. Now go to elements now on right side and select hover

enter image description here

It will show all hover effects

Solution 11 - Google Chrome

Change the CSS so that the property which hides the menu isn't applied while you work on it is what I do.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOJFordView Question on Stackoverflow
Solution 1 - Google ChromemxxkView Answer on Stackoverflow
Solution 2 - Google ChromegmoView Answer on Stackoverflow
Solution 3 - Google ChromeWoppiView Answer on Stackoverflow
Solution 4 - Google ChromepixelearthView Answer on Stackoverflow
Solution 5 - Google ChromeJoshView Answer on Stackoverflow
Solution 6 - Google ChromeMayeulCView Answer on Stackoverflow
Solution 7 - Google ChrometddrmllrView Answer on Stackoverflow
Solution 8 - Google ChromeVodisView Answer on Stackoverflow
Solution 9 - Google ChromeDan HaddockView Answer on Stackoverflow
Solution 10 - Google ChromeSubhabrata BanerjeeView Answer on Stackoverflow
Solution 11 - Google ChromeWoodyView Answer on Stackoverflow