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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:51:57+00:00 2026-05-13T07:51:57+00:00

i have 2 links with same id. <a class=’showtag’ id= . $row[‘id’] . href=”>

  • 0

i have 2 links with same id.

 <a class='showtag' id=" . $row['id'] . " href=''>" . $row['name'] . "</a><a class='removetag' id=" . $row['id'] . " href=''> -</a><br />";

how do i remove the first one by clicking on the second one.

i just need the selector to use with jquery remove().

EDIT: i have tried this one:

$("a[id='" + event.target.id + "']").remove();

but the problem is that it also removes all other of my links that got the same id (i have switched them to class now).

so i need a selector that removes the link before the triggering link and that is a sibling to it (or is next to the triggering link).

thanks

  • 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-13T07:51:58+00:00Added an answer on May 13, 2026 at 7:51 am

    You shouldn’t have two DOM elements with the same ID.

    The ID attribute is assumed to be unique, you will have problems and cross-browser inconsistencies.

    I would recommend you to use a class in your links instead of having duplicate ID’s.

    But as the two anchors are siblings, you can do something like this (notice that you don’t need the id):

    $('.removetag').click(function () {
      $(this).prev('.showtag').remove();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to check if two elements have the same class name?
I have a un-ordered list containing links with the same class and a unique
I have 5 links that are on the same form but I would like
I have a few links that should all open in the same window or
I currently have links w/ class=ajax that I want to retrieve the element with
I have 2 anchor links (a.selector) and when one is clicked it has a
I have the following (simplified) Hibernate entities: @Entity @Table(name = package) public class Package
I have a menu that links to content on the same page and through
I have a CSS class that makes my links look like nice looking buttons.
I have three links that unfortunately do not have a class or an id.

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.