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

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

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