简体   繁体   中英

Conflict between Prototype and jQuery

I'm trying to use the jQuery Datepicker and a JavaCcript scrollbar on one page. But if I declare both in the header file one does not work, is there a way I can fix this but still use both? I've tried the following but to no success:

var $j = jQuery.noConflict();
$j("#datepicker").datepicker();

try :

jQuery.noConflict();
jQuery("#datepicker").datepicker();
<script src="prototype.js"></script>
<script src="effects.js"></script>
<script src="jquery.js"></script>

<script type="text/javascript">
jQuery.noConflict();
 jQuery(document).ready(function($){
     jQuery("a").click(function(){
        //Effect.Shake('shake_demo');//this is prototype.js function
                    //jQuery("#datepicker").datepicker();//for suing Jquery function
    });
});
</script>

<body>
<div id="shake_demo" style="width:150px; height:40px; background:#ccc; text-align:center;">
    <a href="#"  style="line-height:40px;">Click me to shake!</a>

</div>
<a id="aClick" class="aClick" href="#"  style="line-height:40px;">Click me to shake!</a>
</body>

You can resolve conflict and still use $ like this:

jQuery(function($){
    $("#datepicker").datepicker();
})(jQuery)

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