Reputation: 79
I am working with a accordion which have gray scale images on load and on mouse over it images show in its real color.
Where is conflicting J query in my script..
Getting error : $ is not a function
<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="js/kwicks.js"></script>
<script src="js/greyScale.js"></script>
<script>
$j = jQuery.noConflict();
$j(function () {
$j('.greyScale').hide().fadeIn(1000); // fade in the grayscaled images to avoid visual jump
});
$j(window).load(function () {
// user window.load to ensure images have been loaded
$('.greyScale').greyScale({
fadeTime: 500
// call the plugin with non-defult fadeTime (default: 400ms)
});
});
</script>
<script type="text/javascript">
$().ready(function () {
$('.kwicks').kwicks({
max: 535,
spacing: 10,
sticky: false
});
});
</script>
Upvotes: 1
Views: 146
Reputation: 6025
Stick all of your script code in a closure like this:
(function($) {
...
}(jQuery));
Then you can just use $
instead of $j
and there will be no conflict.
Upvotes: 3
Reputation: 33163
jQuery.noConflict();
means that jQuery doesn't use $
anymore but $j
so that $
is freed for other use. If you don't define $
anywhere else, it will remain undefined.
If you have $j = jQuery.noConflict();
it means you have to use $j
(or jQuery
) from then on, or do something like:
(function( $ ) {
$().ready(function() {
$('.kwicks').kwicks({
...
});
});
})(jQuery);
On the other hand, if $
is available, why use noConflict()
at all?
Upvotes: 2
Reputation: 823
After using .noConflict(), you won't be able to access the jQuery Object with $, so you should change all your jQuery calls.
Upvotes: 0