How can I inspect disappearing element in a browser?
JavascriptGoogle ChromeFirefoxFirebugOpera DragonflyJavascript Problem Overview
How can I inspect an element which disappears when my mouse moves away?
I don't know it's ID, class or anything but want to inspect it.
Solutions I have tried:
Run jQuery selector inside console $('*:contains("some text")')
but didn't have any luck mainly because the element is not hidden but probably removed from the DOM tree.
Manually inspecting DOM tree for changes gives me nothing as it seems to be just too fast to notice what have changed.
SUCCESS:
I have been successful with Event breakpoints. Specifically - mousedown in my case. Just go to Sources-> Event Listener Breakpoints-> Mouse-> mousedown
in Chrome. After that I clicked the element I wanted to inspect and inside Scope Variables
I saw some useful directions.
Javascript Solutions
Solution 1 - Javascript
(This answer only applies to Chrome Developer Tools. See update below.)
Find an element that contains the disappearing element. Right click on the element and apply "Break on... > Subtree Modifications." This will throw a debugger pause before the element disappears, which will allow you to interact with the element in a paused state.
Update Oct 22 2019: with the release of v. 70, it looks like FireFox finally supports this kind of debugging 2 3:
Update Sep 15 2020: Chrome has an "Emulate a focused page" option (you can get it from the [⌘]+[P] Command Menu, or Global Preferences) for this exact need. 5 - h/t @sulco on Twitter
Solution 2 - Javascript
An alternative method in Chrome:
- Open devTools (F12).
- Select the "Sources" tab.
- While the element you want is displayed, press F8 (or Ctrl+/). This will break script execution and "freeze" the DOM exactly as it is displayed.
- From this point, use Ctrl+Shift+C to select the element.
Solution 3 - Javascript
- Open console
- Type in
setTimeout(()=>{debugger;},5000);
- Press Enter
Now you have 5 seconds to make your element appears. Once it appeared, wait until the debugger hits. As long as you don't resume, you can play with your element and it won't disappear.
Useful tip to avoid repeating those steps above every time:
add this as a bookmarklet:
- Bookmark any page
- Edit this new bookmark
- Replace the URL/location with:
javascript:(function(){setTimeout(()=>{debugger;},5000);})();
Next time you wish to use this, just click/tap this bookmark.
Solution 4 - Javascript
Verified in 2022
Do the following:
- Open the console and navigate to Elements tab
- Type
command + shift + P
(OSX) orcontrol + shift + P
(Windows) - Type the word
focused
- Select
Emulate a focused page
from the the menu
Now clicking around in the console will not close the element.
Solution 5 - Javascript
I am using chrome on Mac there I've followed above steps but I'll try to explain a bit more:
- Right click and go to inspect element.
- Go to sources tab.
- Then hover on the element.
- Then using keyboard
F8
orCommand(Window) \
. It will pause the screen in a static state and the element won't disappear on hover out.
Solution 6 - Javascript
In Firebug there are different solutions for this:
- You can use Break On Mutate inside the HTML panel. (with this you'll also be able to find out which element it is)
- You can right-click the element and choose Inspect Element with Firebug
Also you may want to follow issue 551, which asks for a way to temporarily block specific events.
Edit:
To find out which element it is you can also enable the HTML panel options Highlight Changes, Expand Changes and Scroll Changes Into View to make the element visible inside the HTML panel.
Sebastian
Solution 7 - Javascript
In my case, I used Expand recursively option on google chrome:
The steps are:
- Inspect the dropdown field
- Find the dynamic DOM (the purple highlight)
- Right-mouse click on that dynamic DOM
- Choose Expand recursively:
- We can see all elements are there
Here is a demo:
Solution 8 - Javascript
Hover over the element with your mouse and press F8 (this in Chrome) to pause the script execution. The hover state will remain in visible to you.
It take you to the sources tab. Go back to Elements tab. This time code will not disapper.
Solution 9 - Javascript
There Could be Dom element and the controller functions fighting at to refresh the session. Running the application by "Start without debugging" helped in my case.
Solution 10 - Javascript
you can view the elements appearing and disappearing in the inspector under elements. If you navigate to the element when it is visible you should be able to see it disappear or see its css change when it status changes.
This is possible with firebug in firefox or the built inspector in chrome.
Solution 11 - Javascript
i had the same problem but i use Firefox it disappear as soon as i open inspect element found a solution: open the 4 dashes(settings) go to web developer > Debugger and immediately press F8 which is the shortcut for the pause that stop the script before it kick and detect that you opened the developers tools