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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:00:25+00:00 2026-05-22T15:00:25+00:00

I am loading content from a different page of my site into a result-container

  • 0

I am loading content from a different page of my site into a result-container (div class).

    $('.result-container').load('../path/otherpage.html #ID');

So far so good, that works.
Now, I need to update any link within the result-container when it s clicked. Reason being, they all links still point to their original location (from where they were loaded from).

The idea is , when clicking on a link, I get the href attribute. If it starts with “files/”, than it is a link relative to the original page (if it starts with something else, it is a link to somewhere else and is ok). So, I need to add to the front of the (just clicked) href “../path/”, to make the final href path look like “../path/files/etc….”.
I have some bits working, but really struggle to piece it all together…. can anyone reach me a hand please?
Thanks!
M.

    $(function() {
    $(".result-container").live("click",   //on click on element
                     function() {
                     $.get($(this).attr("href"), //get the href attribute                                              
                              if ($('a[href^="files/"]'))   //if attribute starts with "files/"
                                 {function() {
                                 var href = $(this).attr('href'); //get the attribute content - guess I could have done that above?
                                 $(this).attr('href', '../start/path/' + href); //append the start path to original path
                                             };
                                 }
                           )};
                           )};

Excellent, Thank you !!!!!
Now I am loading an element from a different page on my site with:

$('.result-container').load(../path/conetent.html #unique-ID); //load conent from different page on my site

on click, it changes every element which starts with “files/” to “../path/files/”:

  $(function() {
    $(".result-container").live("click",
                     function() {
                        $('.result-container').html();
                        var test = $('.result-container').html().replace(/"files\//gi, '"../path/files/');
                        $('.result-container').html(test);                       
                           }); }); 

That works. This changes the original content and displays the altered content after an active click in the .result-container.
Now I am trying to remove the .live(“click”, trigger here. (This trigger is only there, because my initial approach to achieve this was different). But when I remove the “click”, this script does not change the text automatically… Any idea on how this executes and displays the altered content after I load the content from the unique ID container?

  • 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-22T15:00:26+00:00Added an answer on May 22, 2026 at 3:00 pm

    How about just replacing any instance of the string “files/ with “/path/. So something like

    var new_text = $('#my_div').html().replace(/"files\//gi, '"/path/');
    $('#my_div').html(new_text);
    

    You’ll have to forgive me if my regex is a bit off but that should give you an idea.

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

Sidebar

Related Questions

Rigth now, I am using this function to load content from a different page
I'm creating a div with jquery, loading content from webserver with load, and then
I'm dynamically loading different content from db, using ajax. So, when I'm loading plain
I am loading content into a page with ajax that will have live click
I'm loading html content via ajax onto a div (using mootools 1.11 and squeezebox,
I want to load content of my page inside a div element using this
This is my jQuery code: $(document).ready(function() { $(#nav li a).click(function() { $(#ajax-content).html(<div id='loading'><img src='{THEME}/images/loading.gif'
First of all In Jquery loading html frag with dynamic content using load() is
I am trying to load content from 2 different URLS but at different intervals.
On my website, I am loading the content dynamically from database like this e.g

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.