简体   繁体   中英

$ not defined but jQuery IS defined in Wordpress

What might cause Firefox to tell me $ is not defined, but using 'jQuery' works as expected.

I'm on Wordpress 3.4 and Wordpress comes packaged with jQuery. Is it something specific to Wordpress?

jQuery.noConflict() has been called. To resolve this with a minimum amount of code change do this.

Before:

$("your").code(function () {
  $("that").uses($.all("over").the("place"));
});

After:

(function ($) {
  $("your").code(function () {
    $("that").uses($.all("over").the("place"));
  });
})(jQuery);

jQuery在WordPress中以noConflict模式在文档状态下工作: http ://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM