Prevent JQuery From Conflict with Other Libraries

jquery Prevent JQuery From Conflict with Other Libraries photo
JQuery is getting more and more popular, many people are using JQuery in WordPress. The right way to import JQuery to your WordPress is like this:

< ?php wp_enqueue_script(“jquery”); ? >

Rather than using <script> syntax. Remember to run this script before wp_head(). And then you can load your own JavaScript like this:

< script type=”text/javascript”
src=”< ?php bloginfo("template_url"); ? >/js/testScript.js” >< /script>

Also remember you must put this after wp_head().

I recently learn one more thing from Chris Coyier from DigWP, a simple way to prevent JQuery to conflict with other JavaScript libraries. Which is to set JQuery to “no conflict” mode and use “$j” instead of “$”:

var $j = jQuery.noConflict();

$j(function(){
    do something.
}

Feel free to visit our Forum, subscribe our RRS Feed for news updates, and follow us on Twitter.

Related Posts

This entry was posted in Plugins, Tutorials and Hacks, Web Design and tagged , , . Bookmark the permalink.

One Response to Prevent JQuery From Conflict with Other Libraries

  1. Pingback: Video Plus - Embed Videos from Popular Web Hosts | Page 29 | Pligg CMS Forum

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>