“Inspect” a hover element?

后端 未结 9 1893
借酒劲吻你
借酒劲吻你 2020-11-30 18:48

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 C

相关标签:
9条回答
  • 2020-11-30 19:19

    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.

    Screenshots from Firefox 55 and chromium 61.

    0 讨论(0)
  • 2020-11-30 19:24

    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.

    0 讨论(0)
  • 2020-11-30 19:24

    You can also do this in the javascript console:

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

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

    0 讨论(0)
  • 2020-11-30 19:26

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

    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.

    0 讨论(0)
  • 2020-11-30 19:26

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

    0 讨论(0)
  • 2020-11-30 19:28

    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!

    0 讨论(0)
提交回复
热议问题