Search code examples
javascriptjqueryconflictsimpletip

Conflict solution required in jQuery and $ in jquery


I have two pages with a script

jQuery(document).ready(function()
 {      
    jQuery("#"+id).simpletip({
    /*content: 'A simple tooltip2 A simple tooltip2 A simple tooltip2',*/                       
        content: msg,
        fixed: true,        
        position: ["0", positionVal]        

    });
});

but i have one problem, one page is working using above method but another page is working only when i replace jQuery with $. is there any alternative by which I can solve this conflict?

I tried jQuery.noConflict(); and var j = jQuery.noConflict(); method, but it didn't work.


Solution

  • You might have other library there. You can however use $ on both of your pages like this:

    jQuery(function($){
      // use $ now
    });
    

    Or

    jQuery(document).ready(function($){      
       // use $ now
    });
    

    FYI, you can also check what $ resolves to using:

    alert($); // or console.log($)