Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:15:18+00:00 2026-05-29T21:15:18+00:00

How do you just change the text us-test from the value of the link

  • 0

How do you just change the text “us-test” from the value of the link below, without having to replace the whole link, the current method i use replaces the whole link i guess that has to do with the function of .attr, i’m guessing i could achieve this by using .find or something else i really don’t have any clue on how to do it can someone help me on this thank’s.

$(document).ready(function(){ 
 $("#box1").click(function(){
 $("a.mylink").attr("href", "http://google.com");
   });  

 $("#box2").click(function(){
  $("a.mylinktwo").attr("href", "http://yahoo.com"); 
 });   


<a class="mylink" href="http://google.com/en/get.php?chrome=us-test">Test</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:15:19+00:00Added an answer on May 29, 2026 at 9:15 pm

    It depends on what you’re trying to achieve. I wouldn’t suggest complicating things too much, and if you can know before hand what URL to go to, replacing the whole URL would probably be best, and easiest to see what’s going on.

    To replace parts of a string, the replace() method would help.

    var url = $('.mylink').attr('href')
    url = url.replace('us-test', 'replaced-text')
    $('.mylink').attr('href', url)
    

    You can also pass a regular expression as the matching argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reusing a created Object just to change a Date and the ordinal value,
Another newbie question from me. Just checking whether my code below is possible. I.e
Using tiny_mce from https://github.com/kete/tiny_mce to be able to change the format of the text,
I'm attempting to just change the background colour of a webpage upon page load.
Why won't the following C code compile? It seems like it should just change
I haven't really ever done a background navigation rollover, I usually just change the
I will like to know how I can change just one color in a
I'd just like to change this cc211_AMBER_13062012i.II cc211_GROMOS_13062012i.II cc211_CHARM_13062012i.II cc211_OPLS_13062012i.II to cc211_AMBER_15062012i.II cc211_GROMOS_15062012i.II cc211_CHARM_15062012i.II
Second question of the day but hopefully simple, I just need to change the
This bad boy just does not want to change size to fill the dock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.