How to become a jQuery no.conflict expert?

How to become a jQuery no.conflict expert?

Basically, I encounter jQuery conflict errors with JS prototypes. and I'm not a jQuery specialist.

Can I solve all the problems of the conflict. how to get expertise to solve conflicts.

How to find out all the code - jQuery. what if plain javascript and jquery code are mixed in the same js file?

What if the internal js code starts directly with

       var opbox="";

this is the original order that I cannot change

1

<script type="text/javascript" src="jquery.min.js"></script> 

2
I want to remove the conflict error from example.js

<script type="text/javascript" src="example.js"></script>

3

<script type="text/javascript" src="Prototype.js"></script>

4

<script type="text/javascript" src="scriptaculous.js ></script>
+3
source share
3 answers

, Prototype , $ Prototype $, jQuery. $ jQuery, jQuery noConflict jQuery $ , jQuery.

, , $, jQuery, :

$('.foo').hide(); // Hide all elements with class "foo"

jQuery('.foo').hide(); // Hide all elements with class "foo"

, $, . - () $ jQuery.

- script, jQuery:

<script type='text/javascript'>jQuery.noConflict();</script>

... script:

(function($) {

... :

})(jQuery);

(, , .)

, , script , $ jQuery, Prototype $, $ . . , (, window), script . , window, .

jQuery noConflict, ready, .

, bobince , $. , .

+9

$ jQuery.noConflict() jQuery() jQuery.

:

<script>
    $(document).ready(function(){
        // Do some DOM manipulation here
    });
</scipt>

:

<script>
   jQuery.noConflict();

   jQuery(document).ready(function(){
       // Do some DOM manipulation here
   });
</script>
+5

<script>
jQuery.noConflict();
(function($){
   $(function(){
      alert('code here');
   });
})(jQuery);
</script>
+1

Source: https://habr.com/ru/post/1742998/


All Articles