jQuery: Test if jQuery is installed with typeof

April 14th, 2010 by jeremychone

There is a corner case where you need to know if jQuery is running on your page. Let’s say, you are using the ajaxForm plugin and that one of the input is of type “file.” ajaxForm will embed the call in a iFrame and the jQuery will not be included in it. So, for the page (or page fragment) that will be the target of such a call, you need to test if jQuery is running before running the script.

if (typeof($) != "undefined"){
  $(document).ready(....
}

Unfortunately, ajaxForm does not support AJAX call in “text” only which would solve this problem.

One Response to “jQuery: Test if jQuery is installed with typeof”

  1. Bits And Pix » jQuery: Test if jQuery is installed with typeof | Source code bank Says:

    [...] the original post here: Bits And Pix » jQuery: Test if jQuery is installed with typeof If you enjoyed this article please consider sharing [...]

Leave a Reply