Skip to content

Instantly share code, notes, and snippets.

@tregusti
Last active December 21, 2015 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tregusti/1111cbb3324fde25b27d to your computer and use it in GitHub Desktop.
Save tregusti/1111cbb3324fde25b27d to your computer and use it in GitHub Desktop.
Output currently selected element in the browser console
(function() {
var a
setInterval(function() {
var a1 = document.activeElement
if (a !== a1) {
a = a1
var s = a.nodeName.toLowerCase()
if (a.id) s += '#' + a.id
if (a.className.trim()) s += '.' + a.className.trim().split(/\s/g).join('.')
console.log('focused: %s %o', s, a)
}
})
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment