Question: Why wont the If and the Else both work, when both conditions can be met at different times by scrolling below or above ‘.fakeheading’? Is the Else-statement overpowering the If-statement?
JQUERY:
$(window).scrollTop(function() {
$('.grid_12').find(function () {
var $header = $(this);
if ($header.offset().top < $(window).Top()) {
$(".fakeheading").css({position:"fixed"})
} else {
$(".fakeheading").css({position:"absolute"})
}
});
});
additional info/thoughts:
Why wont the ‘if’ statement work, if I have $(".fakeheading").css({position:"absolute"})
in the ‘else’ statement. Either the If, or the Else is working, but they will not both work together like they should. It’s like my code wont obey the if-statement when I have the code that’s contained in the else-statement. but if I mess up the else-statement code,(have it be
posssssition:"absolute"
then the if-statement part of my script works fine.
When you have and IF statement with and ELSE, only the first “true” condition is processed. Thus if the process looks like the following psuedo code:
only the first one will actually process, the second will be not be.
On the other hand if you have:
structure, they both could process if the condition is true
EDIT: One other note if you have:
only the first “true” process will execute, whichever one from the top down, equates to true first.