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 7840855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:56:35+00:00 2026-06-02T15:56:35+00:00

I am learning jquery now. I want to replace the parameters of a url

  • 0

I am learning jquery now. I want to replace the parameters of a url with another on page load. For example here is my code

 <div class="changeparam">
<a href="http://demo.org/post.php?i=123&p=456&s=789">Link</a>
 </div> 

Now I need to change the value of the params i,p and s to different values say abc,def,ghi respectively. How can i do it on page load?

  • 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-06-02T15:56:37+00:00Added an answer on June 2, 2026 at 3:56 pm

    Do you need to know the old values? If not can’t you do something along the lines of the following (this assumes the simple case that all links will have the same query string and would need to be extended if this is not the case):

    $(document).ready( function ( ) {
        // Get the full address from the original link
        var old_fulladdr = $('div.changeparam a').attr('href');
    
        // split it to get the actual file address
        var old_addr_parts = old_fulladdr.split('?');
    
        // This may need something more complex...
        var new_querystring = 'i=abc&p=def&g=ghi';
    
        // This changes the href of the link to the new one.
        $('div.changeparam a').attr('href',old_addr_parts[0] + '?' + new_querystring);
    
    });​
    

    UPDATE:
    I’ve created a more flexible function that takes a querystring, an array of items to be replaced and an array of replacement values then outputs a new query string. Have a look at this jsfiddle: http://jsfiddle.net/LWzZR/1

    Also, I agree with the commenters on your question – whilst it’s possible, it’s not recommended 🙂

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

Sidebar

Related Questions

I've just starting learning jQuery and AJAX. I'm able to load a local page
I am new to jquery and still learning. The code I have right now
I've just started learning Jquery but the examples aren't helping me much... Now whats
I am just learning Jquery templates and trying different things step by step. Now
I am learning jQuery UI. I downloaded a code in which the author made
I started learning jQuery just yesterday, and I like it very much. And now
I've been studying php for about 6 months now and want to start learning
me again! I'm learning a lot from this site! Now.. i want to know
I'm learning some AJAX right now and the jQuery function that is being used
I am learning jQuery. I want to use jQuery inside my jsf 2.0 application.

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.