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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:12:43+00:00 2026-05-23T04:12:43+00:00

How can I change the click binding of an element? Html snippet is: <div

  • 0

How can I change the click binding of an element?
Html snippet is:

<div id="Selected">
<ul>
    <li>element 01<a class="element01-selected">-</a></li>
    <li>element 02<a class="element02-selected">-</a></li>
    <li>element 03<a class="element03-selected">-</a></li>
</ul>
</div>
<div id="UnSelected">
<ul>
    <li>element 01<a class="element01-unselected">+</a></li>
    <li>element 02<a class="element02-unselected">+</a></li>
    <li>element 03<a class="element03-unselected">+</a></li>
    <li>element 04<a class="element04-unselected">+</a></li>
    <li>element 05<a class="element05-unselected">+</a></li>
</ul>
</div>

At the moment, I initialize the bindings like this:

<script type="text/javascript" language="javascript">
$("#Selected ul li a").click(
    function()
    {
        // do stuffs
        return false;
    }
);
$("#UnSelected ul li a").click(
    function ()
    {
    var li = $(this).parent();
    $clone = li.clone(false);
    $clone.children().text("-");
    $("#Selected ul").append($clone);
    return false;
    }
);
</script>

The element is copied to the 1st list but the click bind remains, I want the item clicked to switch to the other binding:

  • + link adds a copy (where + is changed to -) into the 1st list
  • – link of added copy removes the item from the 1st list

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-23T04:12:44+00:00Added an answer on May 23, 2026 at 4:12 am

    Using delegate to attach the events. This way if you add any new element to this it will trigger the fire the same events.

    $("#Selected").delegate("ul li a", "click", function()
        {
            // do stuffs
            return false;
        }
    );
    $("#UnSelected").delegate("ul li a", "click", function ()
        {
        var li = $(this).parent();
        $clone = li.clone(false);
        $clone.children().text("-");
        $("#Selected ul").append($clone);
        return false;
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I change the BorderColor of the Textbox when a user Clicks on
how can I click on a wx.Panel and that changes its color? What is
I can change SQL at runtime. Can I do the same with LINQ ?
I can change the irb prompt mode with irb --prompt prompt-mode I can see
Where I can change compiler options for C# project in VisualStudio 2008 (without command
I know I can change the selectionStyle of a UITableViewCell to make it highlight
I understand that I can change a sql table using the follow sp: EXEC
How I can change the individual region background color of viewport extjs 4. Here
I have a view where the user can change some settings, its basically a
I want a form where user can change password. I am able to encrypt

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.