I am developing some JavaScript that should work with either Prototype.js or JQuery, thus I need some way to identify what is the primary library in use. How can I do that?
You can check for jQuery like this:
if (window.$ === window.jQuery)
Well, you could check for the presence of jQuery:
if(window.jQuery !== "undefined")
{
// jQuery Yay!
}
and then if it is assigned to $
if(window.jQuery === window.$)
{
// jQuery Yay!
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With