Im building a site in joomla and I recently purchased a content slider for it that is built in plain old Javascript, then I built some content boxes that have an animation on them provided by Jquery. Right now the animations work, but the开发者_开发技巧 slider doesn't. I was wondering how I could get the page to work using both. Here's my code
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
<script>jQuery.noConflict();
$(document).ready(function() {
//settings
var opacity = 0.5, toOpacity = 1, duration = 350;
//set opacity ASAP and events
$('.opacity').css('opacity',opacity).hover(function() {
$(this).fadeTo(duration,toOpacity);
}, function() {
$(this).fadeTo(duration,opacity);
}
);
});
</script>
Try calling this after the libraries are loaded:
jQuery.noConflict();
Also, try replacing your jQuery ready function with this:
jQuery(document).ready(function($){
This passes the $ shortcut into the jQuery code block, but should still avoid conflicts outside it.
You can read up on the subject here in the jQuery docs.
Have you checked for potential conficts that may have occurred ($'s in the code)? You can run your jquery script in no conflict mode to fix that
http://api.jquery.com/jQuery.noConflict/
According to the jQuery docs on jQuery.noConflict...
Description: Relinquish jQuery's control of the $ variable.
So that means that after you call it, you must use jQuery
instead of $
for jQuery calls.
For example, change $(document).ready(function() { ... });
to jQuery(document).ready(function() { ... });
.
精彩评论