I have this script code:
$(document).ready(function() {
if ($("div[data-content='content-1']").hasClass("slide--current")) {
$("body").addClass("mobile-app");
$("body").removeClass("web-app");
$("body").removeClass("design-app");
}
if ($("div[data-content='content-2']").hasClass("slide--current")) {
$("body").addClass("web-app");
$("body").removeClass("mobile-app");
$("body").removeClass("design-app");
}
if ($("div[data-content='content-3']").hasClass("slide--current")) {
$("body").removeClass("web-app");
$("body").removeClass("mobile-app");
$("body").addClass("design-app");
}
});
</script>
But for some reason the query only runs the first script code and doesnt follow up if the slide-current
is applied to a different data-content, I have tried adding an else if
to each but that didnt fix anything. Also when data-content 2 and 3
have class "slide--current` nothing applies from my script for some reason...
Am I approaching this the wrong way?