0

I have a piece of JS (below) that in IE9 is giving me the following error:
The value of the property '$' is null or undefined, not a Function object

In FFX, Chrome, and Safari I get no issues. Not sure whats going on here - still learning a bit, so be easy on me if it's obvious :)

Thanks in advance!

 <div id="sample-widget" style="">
    <link rel="stylesheet" type="text/css" href="widget.css" media="screen">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script type="text/javascript">
        function LA_triggerOverlay() {
            $("#la-w-001-overlay").toggle();
        };
       $(function () {
           $("#sample-widget").show();
       });
   </script>
   <div>
       <a href="#" onclick="LA_triggerOverlay(); return false;">
   </div>
4
  • are you loading jQuery or defining $ in a script that comes before this block? Commented Feb 10, 2012 at 23:08
  • 1
    Post the contents of the <head> tag of your HTML document. Commented Feb 10, 2012 at 23:08
  • 1
    As posted, you'd either get the error in all browsers, or none. We'll need more context. :-) Commented Feb 10, 2012 at 23:10
  • Updated the original question a bit...hopefully that makes some more sense Commented Feb 10, 2012 at 23:43

2 Answers 2

3

In latest versions of chrome and FF [and maybe Safari as well] '$' is natively supported as a synonym for document.getElementById()

IE 9 does not support this natively, hence you get the error you stated.

However, as gentleman above points out, you maybe missing a library [most likely jQuery]. I would highly suggest to include jQuery in your page and try the code again.

You can reference jQuery easily via this snippet:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

So if this is the missing piece, it should solve your problem.

Sign up to request clarification or add additional context in comments.

2 Comments

how jQuery doens't go in conflict with chorme and FF then?
You can over-ride functions in JS.. so if you were to define a new $ function, it would over-ride the default one.
0

Presumably you haven't included a script above that code that defines the $ symbol (e.g., jQuery or similar). There is no default $ symbol, it's just a symbol that's used by a couple of popular libraries (jQuery, Prototype, and MooTools primarily). Unless you include one of those with a script tag above your code, you'll get this error — in any browser.

2 Comments

Except that the question states that it works in FF, Chrome and Safari.
@amnotiam: I know, hence my comment to the OP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.