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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:47:55+00:00 2026-06-18T12:47:55+00:00

i have a strange behaviour with a and with img tag inside. I have

  • 0

i have a strange behaviour with a and with img tag inside.

I have a php page with a table that is a list of records.
At the end of every row i have a button for delete row.

This is the code of my table:

<div class='edit' >
    <a id='20' href='#' return;>
        <img src='images/edit.png'  />
    </a>
</div>

Every record, every row of the main table, has the code above, with different id each other.

My script code is:

$("#delete a").click(function(e) {

e.preventDefault();

$('#action').val("delete");
$('#keyAction').val(this.id);

$.ajax({
        type: "POST",
        url: "processAttivita.php",
        data: $("#attivita_form").serialize(),
        error: function(msg) {
            $("#errore").html(msg);
        },
        success: function(msg) {
            // display the errors returned by server side validation (if any)
            ricaricaLista();                

        }
    });     

 // end click delete event  
 });

The first row i try to delete clicking on the image works fine.
On the second one it seems that jquery doesn’t bind “click” event and default href of a element occurs, remaining on the same page due the “#” in href attribute.

Any ideas why the second time jquery doesn’t intercept click on <a> element ?

  • 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-18T12:47:56+00:00Added an answer on June 18, 2026 at 12:47 pm

    You’re using an ID selector #delete a which will only match one (generally the first) element.

    Try using a class, e.g. .delete a.

    The reason you only get one element is because JQuery optimizes any selector that begins with # passes through to document.getElementById, which only returns 1 element.

    Here’s an example of how to use event delegation to achieve the same thing:

    $("#tableid").click(".delete a", function(e) {
        // your code
    });
    

    Your html would need to have an ID on your table and give class="delete" to the container of your delete links.

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

Sidebar

Related Questions

I have recently found a strange behaviour inside of the ASP.NET DropDownList that I
I have a strange behaviour. I am using a rather heavy page (4000 nodes)
i have a strange behaviour i'm seeing that if the user access to session
I encountered some really strange behaviour in Apache. I have a standard let PHP
I'm noticing a strange behaviour in Firefox. I have a banner that's positioned absolutely
I have noticed some strange precision behaviour that I cannot understand, I have some
I have encountered a strange behaviour using dijit.form.select inside a tooltip-dialog. Here's a shortened
I am facing a strange behaviour for an .aspx page. I have DataList called
I have some strange behaviour in my php script. For some reason, I can't
I have a strange behaviour where I execute a methods that run a query.

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.