Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
add css classname and remove css classname using jquery based on the screen resolution

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

enter image description here

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

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.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda