I looked up how to check if jQuery is loaded, so here’s a memo.
When you’re just starting to use jQuery, the error ”$ is not defined” often occurs.
The following code uses the typeof operator to check if jQuery is defined, and if it is, it displays an alert.
if(typeof jQuery != "undefined"){ //Check if jQuery is loaded
$(function(){
alert('jQuery is ready.')
});
}
That’s all.
【Reference】
・jQueryが読み込まれているか判別する方法 - 小窓屋めがね (How to Check if jQuery is Loaded - Komadoya Glasses)
・typeof演算子 - 演算子 - JavaScript入門 (typeof Operator - Operators - JavaScript Introduction)
That’s all from the Gemba.