Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 503 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'undefined' is not a function (evaluating '$(document)')

#1
1. I'm using a WordPress site.
2. I'm including this script in the header.

When the script loads, I get this error:

> TypeError: 'undefined' is not a function (evaluating '$(document)')

I have no idea what is causing it or what it even means.

In firebug, I get this:

> $ is not a function
Reply

#2
Wordpress uses jQuery in [noConflict][1] mode by default. You need to reference it using `jQuery` as the variable name, not `$`, e.g. use

jQuery(document);

instead of

$(document);

You can easily wrap this up in a self executing function so that `$` refers to jQuery again (and avoids polluting the global namespace as well), e.g.

(function ($) {
$(document);
}(jQuery));


[1]:

[To see links please register here]

Reply

#3
I ran into this problem also when including jQuery in my page header, not realizing the host was already including it in the page automatically. So load your page live and check the source to see if jQuery is being linked in.
Reply

#4
Also check for including jQuery, followed by some components/other libraries (like jQuery UI) and then accidentially including jQuery again - this will redefine jQuery and drop the component helpers (like .datepicker) off the instance.
Reply

#5
Use this:

var $ =jQuery.noConflict();
Reply

#6
Two things:

1. Be sure that you have jQuery library added, before your $(document).
2. Then just change all "$" with: jQuery , as the previous comments.
Reply

#7
Try this snippet:

jQuery(function($) {
// Your code.
})

It worked for me, maybe it will help you too.
Reply

#8
I had this problem only on Chrome.

I tried adding

var $ =jQuery.noConflict();

just before calling

$(document).ready(function () {

It worked.

Thanks a lot
Reply

#9
wrap all the script between this...

<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
// Code that uses jQuery's $ can follow here.
});
</script>

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If you need to use another JavaScript library alongside jQuery, return control of $ back to the other library with a call to [$.noConflict()][1]. Old references of $ are saved during jQuery initialization; noConflict() simply restores them.


[1]:

[To see links please register here]

Reply

#10
You can use both jQuery and $ in below snippet. it worked for me

jQuery( document ).ready(function( $ ) {
// jQuery(document)
// $(document)
});
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through