Often I want to inspect an element (e.g. tooltip) that only appears when another element is mouse overed/entered. The element that appears, is made visible via jQuery's mouseenter event.
I can't inspect the tooltip, since the tooltip disappears when my mouse leaves the containing element.
Is there a way to pause JS events so I could hover on the element, then pause the browser's JS, and successfully inspect it?
For an example, try inspecting Twitter bootstrap's tooltips: http://getbootstrap.com/javascript/#tooltips.
It's fairly easy in Chrome 38.0.2094.0.
Here's what it'll look like:
Step-by-step:
Open the DevTools in the Sources panel
Make the tooltip appear by hovering over the button
Press F8 to freeze the page
Switch to the Elements panel and use the magnifying glass icon in the top left to select the tooltip
If the tooltip shows up because of CSS, here's what you can do in that case:
Step-by-step:
Open the DevTools
Select the triggering element in the dev tools (the link)
Right click, and select "force element state", and select ":hover"
Inspect the CSS tooltip
Both Safari's and Chrome's Web Inspector offers checkboxes where you can toggle the :active, :focus, :hover and :visited state of an element. Using those might be even easier.
Safari:
Chrome:
There's also another tricky way to do it :
Go over the element which makes your tooltip appear.
Right click to open the contextual menu.
Move your mouse to your dev tool window and left click anywhere in the dev tool panel.
Your tooltip will stay visible, you will then be able to inspect it in the Element tab.
Tested on Chrome. Doesn't seem to work on Firefox.
While #SomeGuy's answer is excellent (t-up for animated gifs), as an alternative you can always do it programmatically. Just pop open the console and type in the event name
document.getElementById('id').dispatchEvent(new Event('event-type'));
(with pure javascript specific syntax may vary by browser)
Even easier with jQuery:
$('#id').trigger('event-type');
In your example (http://getbootstrap.com/javascript/#tooltips), open the console and type in, for example:
$("button:contains('Tooltip on right')").mouseenter();
And the tooltip appears in the DOM and can be manually inspected/modified:
<div style="top: 14406.9px; left: 1048.25px; display: block;"
id="tooltip952596" class="tooltip fade right in" role="tooltip">
<div style="" class="tooltip-arrow"></div>
<div class="tooltip-inner">Tooltip on right</div></div>
As in the comments, if you move the mouse pointer over the page frame, you can trigger other events such as mouseout. To prevent this you can press F8 (as in the acc. answer) or type debugger; (which is its script equivalent)
Related
I have a webpage where photo previews are displayed when you hover the mouse over certain icons. I want to inspect these preview divs in Firebug, but the problem is that you cannot reach it with the mouse, since the preview will disappear when you move the mouse off the icon!
Is there any solution to this problem?
One possible solution would be to stop the JavaScript by some keyboard shortcut. It must not require to move the mouse cursor, because then the preview would disappear. But looking at answers in "Is it possible to stop a javascript with Firebug without using breakpoints?" it doesn't seem to be possible...
Also note that the element is not hidden anywhere when unseen, it is created on-hover and then removed.
In a case like this: http://www.starplugins.com/cloudzoom a quick solution that works with Firefox/Chrome Developer Tools and firebug is the following:
have the developer tools opened
scroll your page to a position where the element that has the hover effect is a bit covered by the developer tools pane.
this way, when you "mouse-out" of the element and "mouse-in" to the developer tools pane the hover effect is still in action.
It's not the best solution but it might help :)
Update:
(it covers this case and works with Chrome):
have the developer tools opened
right-click on the element you want to examine but don't click "inspect element" or anything else
the pop-up will freeze so you will be able at least to find it in the already opened inspector
For Chrome developer tool. you can select the parent dom node and right-click and then select "Break on subtree modification". For details, checking on https://camerondwyer.com/2018/07/11/how-to-inspect-dynamic-html-elements-that-keep-disappearing-in-chrome/
There is an HTML object that changes after mouseover. I need to inspect the changes and copy it's code, but with firebug I cannot do that (the mouse can be only in one place).
Is it possible to freeze the html while the mouse is on an object and then check the changes in firebug?
Note that, it is not the HTML attribute that changes, it is the content that changes. Another div is added after mouseover. So, it cannot be monitored by Style tab. For example in this link: http://demo.virtuemart.net/index.php/2012-01-13-09-33-20/product-details-layout what happens when mouse is over the product image?
actually i dont have firebug .. but chrome inspector can work for you.. i hope it should be available in firebug also.. check the image
so you can try this one also..
You can stop the script execution when the HTML is changed using the Break On Child Addition or Removal option inside the context menu of the HTML panel.
To use this option you need to enable the Script panel first and reload the page.
Example:
At the page you mentioned just right-click on the <body> tag and choose the Break On Child Addition or Removal option. Then hover the product image. Doing so the script execution will stop and you'll be able to inspect the HTML for the loupe by clicking on the node inside the break notification:
If you are using Chrome you can press F8 while having the developer tools opened.
F8 pauses on next script execution. So if you hover, then press F8, then move your mouse a bit inside the element, you will be able to rightclick -> inspect it.
In Firebug Addon you can make the state permanent with the dropdown-menu at the Style tab.
http://i.imgur.com/pUaWw6b.png
If you want to change the content of an element, you can by editing the HTML directly.
http://i.imgur.com/AbW0z9D.png
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.
(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
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.
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.
Verified in 2022
Do the following:
Open the console and navigate to Elements tab
Type command + shift + P (OSX) or control + 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.
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 or Command(Window) \. It will pause the screen in a static state and the element won't disappear on hover out.
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
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:
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.
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.
enter image description here
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.
I've written an article about debugging CSS of disappearing elements
Using hotkeys to automatically go into debugger mode with hotkeys keyboard shortcut:
Install the shortkeys extension
Click on the extension icon and chose "options":
Configure as follows:
Click "Save shortcuts" button (bottom-right)
Now, go to any page, make sure devtools is opened, and hit CTRL+SPACEBAR keys, while your inspection target element is visible.
I'm using Windows OS and this hotkeys combination is good for me and is not "taken" by any other shortcut, but of course, you can choose any other.
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
I want to see the CSS transition or JavaScript/jQuery animation assigned to a particular element. How should I do it in Chrome DevTools or any other developer tools?
For instance, I visited a Google plus page and I noticed that when I hover on an image it grays out, zooms in and a close button appears in the corner.
Normal:
Hover:
How can I see the code behind this behavior?
Right click on the html elements in elements tab and select :hover options. Now you can see the hover css applied to the particular elements in right-hand side styles tab. Pls refer screen shot
For css transitions, its easy to spot when using the chrome dev tools.
Just right click on the animation you want to view bring up the inspector. Change the state of the element to hover and you can view all the css for the hovered element.
For javascript, you can use the Resources tab in the chrome dev tools to view what scripts fires.. Just go through it.
For your effect.. its most probably Javascript.
they will register a Hover event. a hover event can be added by various methods
in CSS
#someId:hover
{
color:red;
}
in Jquery. $('#someid').hover();
via Unobtrusive jquery. they will attach events in unobtrusive manner
now check for the view source for this method. some where they will attach the events.
There is no easy way with JavaScript as far as I know, but the following is my favorite answer and method when I'm working on css in Chrome., you can force states and inspect hover css etc.
https://stackoverflow.com/a/6778547/941896
Breakpoints are great when one knows where the code is being executed. However, I have a problem where my DIV is being manipulated by some unknown code in a library I'm using. Is there a way to basically set a breakpoint on the node and see when children are added or attributes changed?
In firebug you can set in the html tab "Stop on attribute change"
see : http://getfirebug.com/html
Just for people who have never used Firebug, go to the HTML tab along the top of the Firebug window, navigate to the element you are after by expanding the relevant nodes. (Alternatively right-click the div on the page, and choose "Inspect Element" at the bottom (usually) of the right-click menu. Mousing over the node should, by default, highlight that element on the page.
Then when you have the div node shown in the firebug window, right click on the node and choose "Break On Attribute Change", "Break on Child addition or Removal", "Break on Element Removal", or whichever combination you'd like. And voila!