Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to resolve the conflict between Jquery and JavaScript framework

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 181
    Comment on it

    jQuery-noConflict():

        In order to resolve the conflict between Jquery & any other JavaScript framework that also use the '$' sign as a shortcut the jQuery team implemented a method called the noConflict() method.

        What this method does is that,it releases the hold on the '$' shortcut identifier. But we can still use jQuery keyword for writing our query instead of the '$' sign.

    Example:

    $.noConflict();
    jQuery(document).ready(function(){
        jQuery("button").click(function(){
            jQuery("p").text("jQuery is still working!");
        });
    }); 
    

        We can also create our custom keyword instead of jQuery keyword, as noConflict() returns the reference of jQuery which we can store in any object.

    Example:

    var jq = $.noConflict();
    jq(document).ready(function(){
        jq("button").click(function(){
            jq("p").text("jQuery is still working!");
        });
    }); 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: