Feb
28

How to resolve jquery conflict?

Many a times in the project we have to use jQuery code.And some times this jQuery code gets conflict with some other jQuery code.So to solve that issue i have some solution which will help you to getout from the jQuery conflict issue so that you can get back to your work.

When you are using multiple jQuery files you may lead to the conflict amoung them.Because most of the time jQuery file use “$” in the file as the jQuery reference variable throw out the code.And because of this “$” variable jQuery files get conflict with each other.

To resolve the jQuery conflict issue you can use any of the below option,

Option 1:

When you put jQuery into no-conflict mode, you have the option of assigning a variable name to replace $. ( only once )

<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>var $j = jQuery.noConflict();</script>

Option 2:

You can continue to use the standard $ by wrapping your code in a self-executing anonymous function; this is a standard pattern for plugin authoring, where the author cannot know whether another library will have taken over the $.

<script src="jquery.js"></script>
<script>
jQuery.noConflict();
 
(function($) {
   // your code here, using the $
})(jQuery);
</script>

Option 3:

use jQuery instead of $

Some of the other Options you can find from

http://api.jquery.com/jQuery.noConflict/

Hope this will help you to solve jQuery conflict problem.

 

Arpi

hiii friends… i am doing msc in computer application and information technology. we are here to share our knowledge and idea on shareprogrammingtips.com.

More PostsWebsite

You may like to read this also....

Post comment

*

CommentLuv badge
Follow us on Twitter! Follow us on Twitter!

Search in this website

our sponsors

latest comments

Find us on Facebook

Top Authors

35 posts
saurabh
22 posts
10 posts

Find us on stackoverflow

Polls

Tell us who you are

View Results

Loading ... Loading ...

My Bookmarks

Sponsers Link