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

188
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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