admin管理员组文章数量:1355647
I am having trouble running two javascript files on the same page. I used JQuery.noConflict() (.noConflict/) but no luck.
<script src=""></script>
<script>
google.load("prototype", "1.6.0.3",{unpressed:false});
google.load("scriptaculous", "1.8.1",{unpressed:false});
</script>
<script src="js/jquery.tools.min.js"></script>
<script type="text/javascript">
$jQuery.noConflict();
jQuery(document).ready(function($) {
$("#download_now").tooltip({ effect: 'slide'});
});
function show_text() {
new Ajax.Request('./new.php', {
method: 'post',
parameters: { userid: $('userid').value },
onSuccess: function(r) { $('update').update(r.responseText) }
});
}
document.observe("dom:loaded", function() {
$('loading').hide();
Ajax.Responders.register({
onCreate: function() {
new Effect.Opacity('loading',{ from: 1.0, to: 0.3, duration: 0.7 });
new Effect.toggle('loading', 'appear');
},
onComplete: function() {
new Effect.Opacity('loading', { from: 0.3, to: 1, duration: 0.7 });
new Effect.toggle('loading', 'appear');
}
});
});
</script>
I am having trouble running two javascript files on the same page. I used JQuery.noConflict() (http://api.jquery./jQuery.noConflict/) but no luck.
<script src="http://www.google./jsapi"></script>
<script>
google.load("prototype", "1.6.0.3",{unpressed:false});
google.load("scriptaculous", "1.8.1",{unpressed:false});
</script>
<script src="js/jquery.tools.min.js"></script>
<script type="text/javascript">
$jQuery.noConflict();
jQuery(document).ready(function($) {
$("#download_now").tooltip({ effect: 'slide'});
});
function show_text() {
new Ajax.Request('./new.php', {
method: 'post',
parameters: { userid: $('userid').value },
onSuccess: function(r) { $('update').update(r.responseText) }
});
}
document.observe("dom:loaded", function() {
$('loading').hide();
Ajax.Responders.register({
onCreate: function() {
new Effect.Opacity('loading',{ from: 1.0, to: 0.3, duration: 0.7 });
new Effect.toggle('loading', 'appear');
},
onComplete: function() {
new Effect.Opacity('loading', { from: 0.3, to: 1, duration: 0.7 });
new Effect.toggle('loading', 'appear');
}
});
});
</script>
Share
Improve this question
edited Dec 27, 2011 at 21:52
Rob W
349k87 gold badges807 silver badges682 bronze badges
asked May 29, 2010 at 16:57
patrickpatrick
1,0425 gold badges17 silver badges30 bronze badges
2
- I find it amusing you had to add the PHP tag when this has nothing to do with PHP... – animuson ♦ Commented May 29, 2010 at 17:04
- Read my answer here stackoverflow./questions/8871430/… I did it and it worked – John Max Commented Feb 22, 2014 at 14:11
3 Answers
Reset to default 6I believe $jQuery.noConflict();
in your code is a typo. Use jQuery.noConflict();
.
Another method to solve your problem is by replacing all $
variables with jQuery (provided that $
is referrring to a jQuery object).
Read this:
- How to avoid conflict between JQuery and Prototype
or just search stackoverflow like this:
https://stackoverflow./search?q=jquery+conflict-prototype
load jQuery first and then call this code:
var $jq = jQuery.noConflict();
//Now you can use $jq in place of $ for jQuery;
$jq(".myButton").css("border","2px");
Load other libraries.
本文标签: javascriptJquery and Prototype ConflictStack Overflow
版权声明:本文标题:javascript - Jquery and Prototype Conflict - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743999330a2573567.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论