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

167
Views
Replacing character in href zip_ to zip

This jQuery code works half the time depending on browser. Is there a better way to write this replace. Change and href link with .zip_ to .zip

jQuery("a[href*='.zip_']").each(function() {
  jQuery(this).attr("href", jQuery(this).attr("href").replace(/\.zip_/g, ".zip"));
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your solution is fine but it could be broken up a little bit to make it easier to read. I would personally use:

jQuery("a[href*='.zip_']").each(function() {
  const attr = jQuery(this).attr("href").split(".");
  attr[attr.length - 1] = ".zip";
  jQuery(this).attr("href", attr.join(''));
});

This should work as Mozilla suggests split works in all browsers. Also make sure you are using this in your $(document).ready(). This also makes the assumption .zip is at the end of the href.

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!