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

189
Vistas
How to make my javascript code responsive?

how to tell my simple jquery code to activate the click on my .filter_btn

only when I'm on a mobile or tablet (max-width: 768px)

and not on a desktop ?

<script>

document.addEventListener('DOMContentLoaded', function() {

jQuery(function($){

$('.filter_btn').click(function(event){

$('.content_filter').slideToggle('250','swing','hide');

});
});
});

</script>

<style>
    
  @media all and (max-width: 768px)
{
    .content_filter {
    display:none;
}
} 
    
</style>

as you can see here i can click in desktop mode

make my jquery code responsive

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You could validate the width of the window by using the window.innerWidth property. Something like:

<script>

document.addEventListener('DOMContentLoaded', function() {

    jQuery(function($){

        $('.filter_btn').click(function(event){
            //Here we validate the size of the window, I've had this act wonky
            //before, so you may have to adjust the value
            if(window.innerWidth <= 768) {
                $('.content_filter').slideToggle('250','swing','hide');
            }
        });
    });
});
</script>
about 4 years ago · Juan Pablo Isaza Denunciar

0

You already have a media query set up to hide content over the specified screensize, but you are hiding the .content-filter. If you don't want the .filter_btn to be clicked, then hide it.

If you still want the header to be visible, then have two versions of the header: one that is displayed for small screens that IS clickable, and one that displays on large screens and is not clickable.

about 4 years ago · Juan Pablo Isaza 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