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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:14:27+00:00 2026-06-13T22:14:27+00:00

I am running an ajax function that calls an external page but am having

  • 0

I am running an ajax function that calls an external page but am having trouble selecting an anchor tag that has an image inside of it. The function works when it is plain text but once there is an image inside it ceases to function (except when clicked outside of the image but within the anchor tag).

The html is something like this.

    <div id="add_content">
        <a href="page_1.html"> Text works fine</a>
        <a href="page_2.html"><img src="thumbnail.jpg"/>Image doesn't work</a>
    </div>

    <div id="insert_here"> </div>

An example external page is

    <div id="thumbnails">
        <img src="images/1.jpg"/>
        <img src="images/2.jpg"/>
        <img src="images/3.jpg"/>
    </div>

The script that I am running is

       $(document).ready(function (){
            $('#add_content a').click(function(e){
                e.preventDefault();
                $('#insert_here').load(e.target.href + '#thumbnails').hide().delay(100).fadeIn(500);
            });
       });
  • 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-13T22:14:29+00:00Added an answer on June 13, 2026 at 10:14 pm

    Change e.target.href to this.href:

    $('#insert_here').load(this.href + '#thumbnails').hide().delay(100).fadeIn(500);
    

    If you click on the child image then e.target will be that image, and the image doesn’t have an href property. The click event is bound to the anchors, so within the click handler this will be the anchor that was clicked.

    The reason your current code worked “when clicked outside of the image but within the anchor tag” is because in that case e.target is the anchor itself.

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

Sidebar

Related Questions

I'm running a weird issue here. I have code that makes jquery ajax calls
I have some (potentially) long-running ajax calls that I would like to abort if
I would like to use a setTimeout function so that Ajax calls are only
I am working on a project that has over 40 ajax webservice calls. I
I want a HTML/javascript application, running in a WebView to make AJAX calls that
I am writing an AJAX script that basically calls a PHP page and requests
I'm running an AJAX query on an external page, and am attempting to only
on $(document).ready(function() in index.php, the below AJAX is executed, running the file getData.php: if
I'm running into trouble accessing global variables when I make an AJAX call to
I have an app that sends multiple Ajax requests simultaneously. I was originally running

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.