StickorStay JQuery function, error
Something is wrong but I c开发者_如何学JAVAannot tell what it is.. Can somebody help me please? It's making all of my javascript/jquery fail, you can see it here: http://www.jacoinc.com/new/
I'm no longer getting an error however, it's not working...
var wHeight = $(window).height();
var stickorstay = function() {
$('$supahslide').addClass('stay');
if(wHeight >= 800) {
$('#supahslide').addClass('stick', function() {
$('#supahslide.stay').removeClass('stay');
});
} else {
if(wHeight < 800) {
$('#supahslide').addClass('stay', function() {
$('#supahslide.stick').removeClass('stick');
});
};
};
};
$(window).resize(stickorstay);stickorstay();
The function syntax is incorrect:
$(function stickorstay() { // missing () in your code
// ...
});
The JavaScript error console (in Chrome) clearly pointed that out to me when I tried your page. That's the first thing to check when you've got such problems.
There's a syntax error, indeed.
You declared your function in a wrong way, at the line 26 of your JS file.
In JS you can declare a function in two ways:
stickorstay = function() {
...
}
Or
function stickorstay() {
...
}
Looks like you are missing some ()
s:
var wHeight = $(window).height();
$(function stickorstay(){
$('$supahslide').addClass('stay');
if(wHeight >= 800) {
$('#supahslide').addClass('stick', function(){
$('#supahslide.stay').removeClass('stay');
});
} else {
if(wHeight < 800) {
$('#supahslide').addClass('stay', function(){
$('#supahslide.stick').removeClass('stick');
});
};
};
});
$(window).resize(stickorstay);stickorstay();
Also, maybe you meant $('#supahslide')
not $('$supahslide')
?
精彩评论