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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:29:27+00:00 2026-05-26T13:29:27+00:00

I am trying to write some of my first jquery scripts but I’m having

  • 0

I am trying to write some of my first jquery scripts but I’m having some problem…
My page have a long text with lot of internal links (
<a href="/contents/Foo.htm" class=.internal>Foo</a>
). I’d like that when you click on one of the .internal links, the href path will be opened inside the <div id="article">.

var InternalLink = function() {
    $(".internal").click(function(){
        var path =  $(this).attr("href");
        $.ajax({
            url: "path",
            success: function(data) {
                $('#article').html(data);
            }
        });
    });    
};

I wrote the code shown below and it work perfectly but I am trying to generalize the code to every link with internal class:

$("#article_01").click(function(){
    $.ajax({
        url: 'contents/article_01.htm',
        success: function(data) {
            $('#article').html(data);
        }
    });
});
  • 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-26T13:29:28+00:00Added an answer on May 26, 2026 at 1:29 pm
    <a href="/contents/Foo.htm" class="internal" data-ref="article_01">Foo</a>
    

    JS:

    $(".internal").click(function(){
        var path =  this.href;
        var div = $(this).data('ref');
        $.ajax({
            url: path,
            success: function(data) {
                $('#'+div).html(data);
            }
        });
        return false; // so the link does *not* follow through
    });    
    

    So now all you have to do is change the data-ref to point to the div you want the html to load inside of.

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

Sidebar

Related Questions

I have the following JSON: {COLUMNS:[ID,FIRSTNAME],DATA:[[1,Steve],[2,Jim],[3,Bill],[4,Tony]]} I am trying to write some jQuery that
I'm trying to write some code to remove the first N characters in a
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to write some JS replicating jQuery's fadeIn and fadeOut functions. Here's the
Long story short, I'm trying to write some toast-style popup notifications (similar to Growl)
I'm trying to write some jquery that will call a function when an object
I am trying to write some unit tests for my MVC3 project (the first
I'm currently trying to write some unit test on some javascript files. My first
I am trying to write some code to talk to the SmarterMail API, but
I'm trying to write a jQuery script (I have never written one before and

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.