Search code examples
javascriptjqueryhtmlgetelementbyiddollar-sign

Brief form of document.getElementById(), such as jQuery "dollar-sign" method: $()


I want to use something like:

$('#some_id')  // or anything as brief as this

instead of:

document.getElementById('some_id')

But not by use of jQuery!


Solution

  • Define:

    const $ = document.querySelector.bind(document)