What is the use of jQuery.NoConflict with example?

 jQuery.NoConflict with example code

If we use JQuery and other JQuery plug-ins, we will get issue at any time. For preventing this problem, we will use jQuery.NoConflict() method.  We can use this conflict method in 2 ways. For more interview Questions, please see JQuery Interview Questions.

Please download Free Ever green JQuery PDF Books 

First Way

<html>
<head>
<title>http://aspnettutorialonline.blogspot.com</title>
    <script type="text/javascript" src="plugin.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
        jQuery.noConflict();
        //instead of '$' We have to use JQuery
        jQuery(document).ready(function () {
            jQuery("#divison").hide();
        });
        // Use plug in like this $(...)
        $('#divison1').hide();
        //http://aspnettutorialonline.blogspot.com
    </script>
</head>
<body>
<div id="divison">
http://aspnettutorialonline.blogspot.com
</div>

<div id="divison1">
http://aspnettutorialonline.blogspot.com
</div>
</body>
</html>


Second Way:


<html>
<head>
<title>http://aspnettutorialonline.blogspot.com</title>
    <script type="text/javascript" src="plugin.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
        var $jQ = jQuery.noConflict();
        // We have to use jQuery via $jQ(...)
        $jQ(document).ready(function () {
            $j("divison").hide();
        });

        // We can use plug through $.
        $('divison1').hide();
    </script>
</head>
<body>
<div id="divison">
http://aspnettutorialonline.blogspot.com
</div>

<div id="divison1">
http://aspnettutorialonline.blogspot.com
</div>
</body>
</html>

 

If any one know, any other way please tell in the comments. 

If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar