Home  >  Article  >  Web Front-end  >  Solutions to conflicts between jQuery library and other JS libraries_jquery

Solutions to conflicts between jQuery library and other JS libraries_jquery

WBOY
WBOYOriginal
2016-05-16 18:35:131156browse
Copy code The code is as follows:


<script> <br>jQuery.noConflict(); <br>// Use jQuery via jQuery(…) <br>jQuery(document).ready(function(){ <br>jQuery("div").hide(); <br>}); <br>// Use Prototype with $(…), etc. <br>$('someid').style.display = 'none'; <br></script>

Remember to use jQuery.noConflict( after loading each js library ) to overload, such as prototype and jquery in the example.

Of course we can also not use its default namespace. For example, I like to use $j() instead of jQuery().

Js code
Copy code The code is as follows:

var $j = jQuery.noConflict();
$j(document).ready(function(){
$j(”div”).hide();
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn