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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:41:55+00:00 2026-06-04T16:41:55+00:00

how can i tell jquery to use the <a id=> or <a href=> as

  • 0

how can i tell jquery to use the <a id=""> or <a href=""> as a URL to load on click? For example URL page1.php. either by getting the href, or by getting the id and then appending .php

html

<a id="page1" class="load" href="page1.php">1</a>
<a id="page2" class="load" href="page2.php">2</a>
<a id="page3" class="load" href="page3.php">3</a>

jquery

<script>
    $(document).ready(function () {  
        $(".load").click(loadDynamic);  
    });  
    function loadDynamic() {  
        $("#load_in")  
            .load("",function (content) {  
                $(this).hide().fadeIn("slow");  
                return false;  
        }); 
    }  
</script>
  • 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-04T16:41:57+00:00Added an answer on June 4, 2026 at 4:41 pm

    Use this.href to get the href.

    $(document).ready(function() {
        $(".load").click(loadDynamic);
    });
    
    function loadDynamic() {
        $("#load_in").load(this.href, function(content) {
            $(this).hide().fadeIn("slow");
        });
            return false;
    }​
    

    Of course you can use this.id + ".php" as well.

    Note that you wrote return false inside the load callback thus it won’t prevent the default anchor click! You should move it to the outer scope like in the answer.


    For those of you complaining about .click(fn) against on('click', fn)

    Those are the same function, .click(fn) is an alias for on('click', fn):

    In the first two variations, this method is a shortcut for .bind(“click”, handler), as well as for .on(“click”, handler) as of jQuery 1.7.

    jQuery docs

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

Sidebar

Related Questions

Can someone tell me how to install this? I go here: http://api.jquery.com/browser/ and click
I would like to use jQuery in ASP.NET User Control. Can some one tell
How can I tell jQuery to automatically use jsonp for cross-domain ajax requests while
dear all..i'm newbie at time picker. can you tell me how to use jquery
can somebody tell me what is jQuery plugin? I have used the jQuery library
Hi can someone tell me what i'm doing wrong in this jquery statement. I
can anybody tell me why is the following code not working? <script type=text/javascript src=../../Scripts/jquery.js></script>
am currently studying jquery, can someone tell me the things that javascript native can
In a JQuery getJSON call, how can I tell the length of the JSON
can somebody help me and tell me why I can't center the JQuery UI

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.