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

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

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