I can't get this thing right.
Why jQuery() outputs an object by default? And is there some way to achieve same result with JavaScript?
jQuery('#configurator-material')
init [section#configurator-material.section, context: document, selector: "#configurator-material"]
document.querySelector('#configurator-material');
<section id="configurator-material" class="section" ng-controller="materialCtrl as material">…</section>
document.querySelectorAll('#configurator-material');
NodeList [section#configurator-material.section]
In general my problem is that at some point I have this line:
jQuery('#myid').addClass('myclass');
im trying to replace it with JS like this:
document.querySelector('#myid').classList.add('myclass');
I thought that it should be fine and without errors,
but i'm getting "Cannot read property 'classList' of null" on the JS variant if a specific element does not exists on the page.