Ok, this is probably really a noob question, but I'll ask anyway!
At the moment, my function is defined like this:
function checkSize(size, otherSize, el) {
if ($(el).width() <= 800) {
size = otherSize;
}
alert(size);
}
but this wont work.
What does work is:
function checkSize(size, otherSize, el) {
if ($(el).width() <= 800) {
size = otherSize;
} else {
size = 5;
}
alert(size);
}
But that hardcoded value there is obviously really bad.
So actually, I want size only to be otherSize if the condition is true, else size should pass unaffected. How do I do it?
sizeshould pass unaffected" - excuse me ? In your first snippet,sizewill be exactly what was passed into the function invocation, when the condition does not match.size.size = 5;overall?