Skip to content

Instantly share code, notes, and snippets.

@adambankin
Created July 11, 2016 22:15
Show Gist options
  • Save adambankin/b35caf59a2fbf4c308c028d4ffcdd6ee to your computer and use it in GitHub Desktop.
Save adambankin/b35caf59a2fbf4c308c028d4ffcdd6ee to your computer and use it in GitHub Desktop.
/*
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