Last Updated: February 25, 2016
·
1.404K
· eriwen

DOM debugging helper functions

Paste these into your browser JavaScript console for navigating the DOM more quickly while debugging:

function $(id) {
    return document.getElementById(id);
}
function $t(tag, context) {
    return (context || document).getElementsByTagName(tag);
}
function $$(expr, context) {
    return (context || document).querySelectorAll(expr);
}

This works great with Chrome Canary's new Snippets feature.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside