Reputation: 8719
I am getting the following error
Uncaught TypeError: Property '
$
' of object [object global] is not a function in line 2:
Using the following code:
$(document).ready(function() {
$('#tabs > ul').tabs({ fx: { opacity: 'toggle' } });
$('#featuredvid > ul').tabs();
});
The problem appears local at 127.0.0.1 only, while same code OK online! I'm dazzled, any ideas?
Upvotes: 16
Views: 59985
Reputation: 93531
Simply, use the following :
jQuery(function() {
//Your code when document will be ready
});
Upvotes: 1
Reputation: 51
I got the same error and solve it by adding
var $ = jQuery;
as a global var on my script
Upvotes: 3
Reputation: 491
I had pretty much same problem. The error message says
TypeError: $ is not a function
$(document).ready(function() {
The line in my code that was throwing error is this :
$(document).ready(function(){
In my case the problem is that $ is not recognized as jquery. I had to replace $ with the keyword jQuery. So finally i changed my code like this:
jQuery(document).ready(function(){
And it worked.
Upvotes: 6
Reputation: 4411
Use this instead:
jQuery(document).ready(function($){
$('#tabs > ul').tabs({ fx: { opacity: 'toggle' } });
$('#featuredvid > ul').tabs();
});
Upvotes: 11
Reputation: 5036
I ran into this error when I was trying to use the slide effect that I thought was part of jQuery but was actually a jQuery UI effect. This was the output from my console:
Uncaught TypeError: Property '#<Object>' of object #<Object> is not a function
So, to me it seems like you just need to include the jquery UI library. Add this line after you include jQuery.
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
Upvotes: 35
Reputation: 786
Check to see if any other script you are using is calling jQuery.noConflict(). Doing so releases the $
binding, thus causing the $
symbol to be undefined.
One way to fix this is to add $
as the first parameter of your callback function:
$(document).ready(function($) {
...
}
This works because the global jQuery object is passed as the first parameter to a .ready()
handler. See also http://api.jquery.com/ready/
Upvotes: 16
Reputation: 792
I had the same error with tabs and after some digging in jQuery documentation I found this: http://docs.jquery.com/Using_jQuery_with_Other_Libraries#Overriding_the_.24-function
Once I overrode the jQuery it was working. So it seems like I had some namespace problems.
Upvotes: 3
Reputation: 5797
It might be the version of jQuery or something along those lines. I had this exact problem - I was using a local copy of jQuery (version 1.3.2) and then switched to http://code.jquery.com/jquery-latest.pack.js and suddenly it worked (latest at the time was 1.4.1).
I also had some of the issues you mentioned about "Resource interpreted as script but transferred with MIME type text/plain". I think that's safe to ignore for this particular problem as it still shows up for me even though my javascript is working now.
Upvotes: 0
Reputation: 196236
Is jquery available locally ? (the error you mention usually means that the jQuery is not available - loaded)
Perhaps you are loading it from a relative path and the structure is different to the online version ..
Upvotes: 2
Reputation: 14031
Might be a browser security setting, blocking JS to run locally, are you using IE by any chance? Try with Firefox or play with your security settings in IE
Upvotes: 1