Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!