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

  • Home
  • SEARCH
  • 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 8938573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:39:26+00:00 2026-06-15T10:39:26+00:00

I have a link that wired up to a jQuery function. It is inside

  • 0

I have a link that wired up to a jQuery function. It is inside an <li> with another link. Code here:

<li id="aps_pdf1">
   <a target="_blank"" href="....">1testpdf.pdf</a>
      <span style="padding-left:40px">
           <a id="delete-aps_pdf1" class="delete_pdf" title="Delete this PDF." href="#">Delete</a>
      </span>
</li>

I’m trying to replace the first link with a file upload control when the delete-aps_pdf1 is clicked by replacing the html with jQuery. Here’s what I have so far with my code:

jQuery(document).ready(function($) {
    $('.delete_pdf').each(function(i,e) { //grab the link class delete-pdf
        var id = $(this).attr('id').replace(/delete-/, '');
        var li = $(this).closest('li').attr('id');
        $(this).click(function(){
            //alert('Clicked! '+ id);//$(this).attr('id'));  //THIS WORKS WHEN CLICKED
            //alert(li);
            $(li).replaceWith('<input type="file" style="width: 700px;" name="' + id + '" id="' + id + '" />');

        });
    });

My replaceWith doesn’t seem to be working at all. I’m relatively new with jquery and I’ve done this reading documentation so I’m sure I’m missing something somewhere.

A step in the right direction would be greatly appreciated!

  • 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-15T10:39:27+00:00Added an answer on June 15, 2026 at 10:39 am

    You’re trying to replace a string. Pass the jQuery object instead:

    jQuery(document).ready(function($) {
    $('.delete_pdf').each(function(i,e) { //grab the link class delete-pdf
        var id = $(this).attr('id').replace(/delete-/, '');
        var li = $(this).closest('li');
        $(this).click(function(){
            //alert('Clicked! '+ id);//$(this).attr('id'));  //THIS WORKS WHEN CLICKED
            //alert(li);
            $(li).replaceWith('<input type="file" style="width: 700px;" name="' + id + '" id="' + id + '" />');
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
When I have a link that is wired-up with a jQuery or JavaScript event
I have a link that opens a Thickbox... <a href=page.php?tag=lists-element&keepThis=true&TB_iframe=true&height=450&width=500> Everything works with this
I have a link that looks like this: <a onclick=myLightbox rel=lightbox href=image.jpg title=> I
I have a link that leads to an image. <a href=/images/foo.png> <img src=/images/thumbnails/foo.png width=27
I have a link that loads a page and calls a javascript function on
I have a link that I want to center vertically in the .well class
I have a link that, when clicked, should deliver an email by using an
I have a link that I want to look like a button so I
I have a link that recieves a dyanamic image via php, and when you

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.