I am trying add classname and remove classname based on the resolution using jquery.
Here is my Jquery code. In mobile mode I am getting totopDesk in desktop mode I am getting totop_tab only in tablet mode I am getting correct class. What I am doing wrong here
function isMobile(){
if($(window).width() <= 575){
return true;
} else {
return false;
}
}
function isTab(){
if($(window).width() > 575 && $(window).width() <= 992){
return true;
} else {
return false;
}
}
function isDesktop(){
if($(window).width() >= 992){
return true;
} else {
return false;
}
}
$(window).resize(function ()
{
if (isMobile()) {
goMobile()
}
else if (isTab()) {
goTablet()
}
else {
goDesktop();
}
})
function goDesktop()
{
$("#go_btn").addClass("totopDesk");
$("#go_btn").removeClass("totop_tab");
$("#go_btn").removeClass("totop_mob");
}
function goMobile() {
$("#go_btn").addClass("totop_mob");
$("#go_btn").removeClass("totopDesk");
$("#go_btn").removeClass("totop_tab");
}
function goTablet() {
$("#go_btn").addClass("totop_tab");
$("#go_btn").removeClass("totop_mob");
$("#go_btn").removeClass("totop");
$("#go_btn").removeClass("totopDesk");
}
without Jquery simple using @Media query I am getting this issue
When I am in Tablet mode in the inspect element 48em class got strike out it showing only deskop css
According to your picture, you have your media query at line 23 in your main.css file, and the rest of your code starting at line 71 in your main.css file. You need to move the media query after the main styles you are trying to change. CSS reads from top to bottom and applies the bottom most styles. Since your media query comes before the main styles, it is not being applied.