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

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

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