JohnC1 JohnC1 - 1 year ago 94
jQuery Question

Use $(Selector) without jQuery

I am currently using something like this:

function Select(query)
return query[0] === '#' ? document.querySelector(query) : document.querySelectorAll(query);

I have to use it like:

Select('#id').innerHTML = "content", or Select('.class')

Is there a way I can use $('#id) or $('.class') without jQuery?

Answer Source

Add window.$=Select or change name of function to $

This won't enhance any capabilities...just shorten the code when you use it

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download