This is sort of a two question into one. I'm trying to use the jquery no conflict but I don't think I'm doing it correctly.
This is wat I have:
// **************** PLUGINS ****************
jQuery.noConflict() // return `$` to it's previous "owner"
(function($){ // in here you're assured that `$ == jQuery`
$(document).ready(function() {
$(".fancybox").fancybox(); /*LIGHTBOX*/
});
$(window).scroll(function(){ /*SCROLL TO TOP*/
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
$('.bxslider').bxSlider();
});
Am i not doing it right? Also, when I add this it makes everything stop working which is why I think I'n not adding the no conflict correctly:
// **************** HEADER SHADOW ****************
$(window).scroll(function() {
if ($(this).scrollTop() == 0) {
$('header').css({
'box-shadow': 'none',
'-moz-box-shadow' : 'none',
'-webkit-box-shadow' : 'none' });
}
else {
$('header').css({
'box-shadow': '0px 10px 10px #888',
'-moz-box-shadow' : '0px 10px 10px #888',
'-webkit-box-shadow' : '0px 10px 10px #888' });
}
});
Thank you in advance.
This is sort of a two question into one. I'm trying to use the jquery no conflict but I don't think I'm doing it correctly.
This is wat I have:
// **************** PLUGINS ****************
jQuery.noConflict() // return `$` to it's previous "owner"
(function($){ // in here you're assured that `$ == jQuery`
$(document).ready(function() {
$(".fancybox").fancybox(); /*LIGHTBOX*/
});
$(window).scroll(function(){ /*SCROLL TO TOP*/
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
$('.bxslider').bxSlider();
});
Am i not doing it right? Also, when I add this it makes everything stop working which is why I think I'n not adding the no conflict correctly:
// **************** HEADER SHADOW ****************
$(window).scroll(function() {
if ($(this).scrollTop() == 0) {
$('header').css({
'box-shadow': 'none',
'-moz-box-shadow' : 'none',
'-webkit-box-shadow' : 'none' });
}
else {
$('header').css({
'box-shadow': '0px 10px 10px #888',
'-moz-box-shadow' : '0px 10px 10px #888',
'-webkit-box-shadow' : '0px 10px 10px #888' });
}
});
Thank you in advance.
Share Improve this question asked Feb 18, 2013 at 16:16 DanielDaniel 552 silver badges10 bronze badges 2-
When you say "add this", you mean inside the block
(function($){ })(jQuery)
or after ? EDIT : following Robert's answer I see you just forgot to passjQuery
... – Denys Séguret Commented Feb 18, 2013 at 16:18 - In the same block, so it's all one thing. For the purpose of this question it's shwoing separate but I was just copying and pasting under the $('.bxslider').bxSlider(); – Daniel Commented Feb 18, 2013 at 16:38
1 Answer
Reset to default 8You have to pass jQuery in to you function:
jQuery.noConflict() // return `$` to it's previous "owner"
(function($){ // in here you're assured that `$ == jQuery`
// Code
})(jQuery); //Do you mean to pass jQuery like this perhaps?