Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda