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

88
Views
Dynamically Changing text with jQuery

I have a script which calls and displays the users phone number to them on a header. That works great. However, I am needing to change text on the page that I can't edit directly. There is a phone number that I am needing to replace with the same ID as the header.

Help me change the href 800 number and the span 800 number with jQuery please! I'm stuck!

The code below is hard coded and I don't have access to change it. So it must be done dynamically.

<div class="flex-item flex-item-nogrow navbar-icon" id="navbarPhoneNumber">
                <a href="tel:8005555555" class="flex-wrapper align-items-center navbar-icon-link">
                    <i class="fa fa-phone" aria-hidden="true"></i> <span>(800) 555-5555</span>                </a>
            </div>

I have tried this

$("#navbarPhoneNumber a").html("<i class='fa fa-phone' aria-hidden='true'></i><span id='phonenumber'></span>");

It didn't work.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

$("#navbarPhoneNumber a").replaceWith("<i class='fa fa-phone' aria-hidden='true'></i><span id='phonenumber'></span>");

Try This

about 4 years ago · Juan Pablo Isaza Report

0

var $phoneNumberA = jQuery('#navbarPhoneNumber a');
var $phoneNumber = jQuery('#navbarPhoneNumber span');

$phoneNumberA.attr('href', $phoneNumberA.attr('href').replace(/(tel:...)/, 'tel:123'));
$phoneNumber.text($phoneNumber.text().replace(/\(.*\)/, '123'));
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!