Home > Web Front-end > JS Tutorial > body text

Solutions to conflicts between jQuery library and other JS libraries_jquery

WBOY
Release: 2016-05-16 18:35:13
Original
1154 people have browsed it
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();
});
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!