You don’t need jQuery for Selctors

By 30th October 2017 September 4th, 2018 How to, Tutourial & Tips

If you want to use the jQuery style to select elements you can add the below code to your project without loading the full jQuery Library.

window.$ = function(selector) {
    var selectorType = 'querySelectorAll';

    if (selector.indexOf('#') === 0) {
        selectorType = 'getElementById';
        selector = selector.substr(1, selector.length);
    }

    return document[selectorType](selector);
};