I have a piece of JS code that determines whether there is a vertical scrollbar and applies a CSS class to an element. Nothing big.
What is confusing me is it appears to be doing the opposite of what I understand it should be doing. This isn't a problem unless it is a bug and is fixed in the future.
The code:
if (document.body.scrollHeight > document.body.clientHeight) {
var d = document.getElementById("footer").className = "footernoscroll";
}
My understanding is that it will apply the class if there is a vertical scroll bar, but it appears to be applying the class if there isn't a scroll bar. Am I interpreting this correctly and the code is acting strangely or is my interpretation wrong?
EDIT: Thought I should add, if I reverse the operator the effects will be reversed and it will use the else
part of the statement instead.