Exploring the differences between two fiddles (make sure to run the code on the jsfiddle pages to see the differences clearly).
Simple demonstration:
$("body").addClass("noScroll");
alert($("body").hasClass("noScroll"));
$("body").removeClass("noScroll");
alert($("body").hasClass("noScroll"));
Accompanied by this css:
.noScroll {
background-color: pink;
position: fixed;
width: 100%;
top: 200px;
}
In this example, a class is added to the body element, altering its appearance and behavior. The class is then removed, returning the body to its default state. Everything works as expected.
$("body").addClass("noScroll");
alert($("body").hasClass("noScroll"));
$(".noScroll").css({
"background-color" : "pink",
"position" : "fixed",
"width" : "100%",
"top" : "200px"
});
$("body").removeClass("noScroll");
alert($("body").hasClass("noScroll"));
This time, there is no accompanying CSS as it is added through jQuery. Despite similarities to the first example, the CSS is applied but not properly removed. What could be causing this issue?
Thank you!