Created
July 11, 2016 22:15
-
-
Save adambankin/b35caf59a2fbf4c308c028d4ffcdd6ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Open a page in Chrome and go to about:blank | |
Then, in Dev Tools, paste the code below into the console | |
After 10 seconds you'll see <div id="myElement"> in the console | |
*/ | |
(win => { | |
win.obj = { | |
fetch: o => setTimeout(o.success, 10000) | |
}; | |
})(window); | |
(body => { | |
// populate the body | |
body.innerHTML = ` | |
<div id="myElement"> | |
<div id="clickableElement">Click Me</div> | |
</div> | |
`; | |
// get a reference to the DOM element | |
const domElement = document.getElementById('myElement'); | |
// create a callback that contains the reference | |
obj.fetch({ success: () => console.log(domElement) }); | |
// empty the body | |
body.innerHTML = ``; | |
})(document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment