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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:24:37+00:00 2026-05-16T18:24:37+00:00

I have a UL that contains items that the user can click on and

  • 0

I have a UL that contains items that the user can click on and move from one list to another. I have a function to inspect the list item and move it from one list to another and it works well — except for one problem.

The list item contains an image (which also responds to the click event). So if my user clicks on the image (essentially a + or – sign that represents add/remove) the function does not work, as the element that it expected as the target is the image, not the list item. How can I delegate the image click to the li that contains it?

The list item is built using struts2 iterator

        <li class="ui-widget-content" id="<s:property value="userId"/>">
            <img src="/images/add_16.png" border="0" alt="add"/>
            <s:property value="firstName"/>&nbsp;<s:property value="lastName"/>
        </li>   

I tried this…

$("#ul-available li").delegate("img", "click", function(){
        $(this).click();
    });

…thinking that if I click the image I could simply invoke the click event on the list item, but it doesn’t work. Any ideas what I am doing wrong, or any other ideas on how to accomplish this would be much appreciated.

Thanks to any/all replies!

  • 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-16T18:24:38+00:00Added an answer on May 16, 2026 at 6:24 pm

    Inside .delegate() this is referring to the <img> still, you need to crawl up to the <li>…using .closest() is a good method, like this:

    $("#ul-available").delegate("li img", "click", function(){
      $(this).closest("li").click();
    });
    

    .delegate() is also intended to capture clicks, so it’s better up on the <ul> instead of on each <li>, I’ve made this adjustment above.

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

Sidebar

Related Questions

I have an activity that contains several user editable items (an EditText field, RatingBar,
I have a List that contains items, for example: 1) https:\\10.12.23\\ 2) https:\\12.23.12.25\\ 3)
I have a list box control that contains enough items to list them with
I have a Silverlight 2.0 DataGrid that contains a list of items that needs
i have a menu that contains just one item. Button exit; @Override public boolean
In my process, I have a page that the user can select various items
I have a ListBox that contains a number of User items that are DataTemplate
I have a Model than contains a collection of items that can be modified.
I have a collection that contains all the items that I want to keep
I have a div that is position: absolute and it contains items that get

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.