How to resolve jquery conflict?

By -

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>
(function($) {
   // your code here, using the $

Option 3:

use jQuery instead of $

Some of the other Options you can find from

Hope this will help you to solve jQuery conflict problem.

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

Leave a Reply

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