Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examine Element That is Removed onblur

So I have an element that is dynamically added to the page with Javascript. After it is added, it is granted focus.

I want to examine the element in chrome dev tools, but the issue is that it has a onblur event handler that removes it from the DOM. So basically when I click on the dev tools to select the element, it is removed. An example can be seen here:

http://jsfiddle.net/MSZEx/

HTML:

<div id="container">     <button id="the_button">Click me to show field</button> </div> 

Javascript:

$("#the_button").click(function() {     $elt = $("<input>").attr("type", "text").attr("id", "text_field");     $("#container").append($elt);     $elt.focus();     $elt.blur(function() {        $elt.remove();      }); }); 

In the example I would like to be able to examine the input element that shows up once the button is clicked.

like image 667
thatidiotguy Avatar asked Jun 18 '14 14:06

thatidiotguy


People also ask

How do I inspect hidden elements in Chrome?

VIEW HIDDEN ELEMENTS: The extension makes visible those elements hidden by the "display:none", "type=hidden", and "visibility=hidden" attributes / styles. To do this hit LazySec's "Show Hidden Elements" button.

How do I inspect a dynamic dropdown?

Right-click on the dropdown, click Inspect Element, and find it in the devtools. Left-click on the dropdown to open it. Right-click on an option in the open dropdown but do NOT click Inspect Element. Press Escape to close the context menu.


2 Answers

I got it working by right clicking the parent node in the tree without focus & then

-> Break on... -> Subtree Modifications

Note that a page refresh doesn't clear this out, so might have to close & reopen the inspector if you have forgotten where you put your break point

like image 171
James879 Avatar answered Sep 19 '22 12:09

James879


Rightclick the node in the element tree -> Break on... -> Node Removal.

The debugger will now break before the node gets removed.

like image 34
darthmaim Avatar answered Sep 19 '22 12:09

darthmaim