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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:23:11+00:00 2026-05-24T03:23:11+00:00

For example i have such code: $(#total).html(Price $<span> + value + </span>); And i

  • 0

For example i have such code:

$("#total").html("Price $<span>" + value + "</span>");

And i also want to add a href button there

$("#total").html("Price $<span>" + value + "</span><a id='remove' href='#'>remove</>);

But how i may add onclick event for that a href?

UPDATE

I really like that solution:

//Create the link to remove the item beforehand, and add the onclick event handler.
var removeLink = $("<a id='remove' href='#'>remove</a>").click(function(e) {
    //Click event handler here.
});

$("#total").html("Price $<span>" + value + "</span>");  //Create the price value
$("#total").append(removeLink);  //Add the remove link.

Because there is a lot of remove links going to be on my form, but i have a question how to pass any parameters to that click function in such case?

  • 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-24T03:23:12+00:00Added an answer on May 24, 2026 at 3:23 am

    Try something like this:

    //Create the link to remove the item beforehand, and add the onclick event handler.
    var removeLink = $("<a id='remove' href='#'>remove</a>").click(function(e) {
        //Click event handler here.
    });
    
    $("#total").html("Price $<span>" + value + "</span>");  //Create the price value
    $("#total").append(removeLink);  //Add the remove link.
    

    It’s a bit more verbose than a one liner, but it’s very readable in my opinion.


    In response to your comment below, if you want to pass parameters, you can do it in many ways. Since you’re using Jquery, there are two main ways I can think of off the top of my head:

    Method 1: Taking avantage of anonymous functions being able to access variables in outer scope

    var param = 1234;                // <-- We know this value before we create the link
    var removeLink = $("<a id='remove' href='#'>remove</a>").click(function(e) {
        var someVariable = param + 4321;
        alert(someVariable);        //Shows "5555" in a message box when link is clicked.
    });
    

    Method 2: Using jQuery.data

    var param = 1234;                // <-- We know this value before we create the link
    var removeLink = $("<a id='remove' href='#'>remove</a>").click(function(e) {
        var someVariable = jQuery.data(this, 'param') + 4321;
        alert(someVariable);        //Shows "5555" in a message box when link is clicked.
    });
    jQuery.data(removeLink, 'param', param);    // <-- Save the param as a Jquery data value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have some openGL code (such code for example) /* FUNCTION: YCamera ::
I'm trying to work with sockets and I have such problem In code example:
Is it something wrong or jquery bug? So we have such code for example
For example, I have such a code: <?php $A = array( 'echoSmth' => function(){
For example I have such query: Query q = sess.createQuery(from Cat cat); List cats
If I for example have <p> some long text </p> on my HTML page,
Why does: const char example; (uint64*)example have a value of 140734799798420 and *(uint64*)example have
I have one question, I have such code this._engine = Python.CreateEngine(); ScriptSource source =
For example i have a datagrid and want to do something with it before
Problem I have such code var ls = src.iter.toList src.iter = ls.iterator (this is

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.