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

120
Visualizações
Can I custom default queryselector of Jquery?

I have problems when using postcss-modules to obfuscate class names.

I add the prefix and suffix to start and end of class names likes .ABC_className_XYZ.

And now when writing JS(Jquery), I need to convert the class name to the same format.

I write a function to convert that.

But now, whenever i write JS(Jquery) i will have to write in the format $(className("some_class_name")).

Does anyone have a solution to modify the queryselector, so that we only need to write the class of the element each time, without passing it through the name conversion function?

NOTE: could somehow include all query functions like: $(), addClass(), removeClass(), hasClass(), closets(), .... And it only changes with the class, the id and tag won't change

Thank you very much.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here is one solution, monkey patch:

$__ = (function(cls){
    const myHash = {};
    return function(cls){
       let converted = myHash[cls] || (myHash[cls] = className(cls));
       return $_(converted);
    }
}());

If you want replace $__ with $_ directly, or maybe Jquery has an inbuilt method to modify prototype methods, you might want to check that first

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