简体   繁体   中英

Resolve Javascript Conflicts / jquery

I am trying to add jQuery to the PHP of SQLBuddy and am getting some conflicts. If I just include jQuery, the rest of the program stops functioning and doesn't pull the tables / databases.

If I use the jQuery noConflict function, everything works, but I can't use any jQuery selectors. Is there a way to merge 2 libraries that will show you where there are 2 functions with the same name and prompt you to rename one of them?

noConflict returns a reference to the jquery function, so you should just be able to assign the return value to a variable and use that instead of $ or jquery . Like so:

var $j = jQuery.noConflict();
// $j is now an alias to the jQuery function; creating the new alias is optional.

$j(document).ready(function() {
    $j( "div" ).hide();
});

see: http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM