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

203
Vistas
Remove/replace space from value of div ID

I have a manufacturer directory page, each manufacturer div ID is dynamically populated by the brand name. The goal is to allow manufacturers to share their link with their customers (ex:https://libraries.specifiglobal.com/partners/request-foodservice-equipment-libraries/#angel-po)

Obviously this isn't perfect since names often include spaces and/or an apostrophe. The functionality I am trying to achieve is to ideally replace spaces with dashes and remove the apostrophe altogether.

I have tried the code below, however it changes all div ID's to the first manufacturer in a list.

var myText = jQuery('.card-header').closest(".w-100").attr("id");
var newMyText = myText.replace(/ /g,'-');

// remove older id and place new id
jQuery('.card-header').closest(".w-100").attr("id", newMyText);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

jQuery('.card-header')
    .closest(".w-100")
    .each(function() {
        e = jQuery(this);
        e.attr('id', e.attr('id').replace(/ /g,'-'));
    });
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