简体   繁体   中英

Wordpress loading external jQuery files

Is it possible to load external jQuery files while allowing those files to use the "$" sign? Without changing the external jQuery files?

Currently, I'm using the wp_enqueue_script function to add the scripts to my site, but since WordPress runs jQuery in compatibility mode the scripts do not have access to the "$" and are forced to use "jQuery" instead. I know how to fix this issue for the local jQuery files on the website, but I have no clue on external files which I cannot edit.

Have you try to use noConflict() in jQuery? If not then try with the following line of code

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

https://api.jquery.com/jquery.noconflict/

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