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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:51:29+00:00 2026-06-01T02:51:29+00:00

Recently I was asked on a page with 10K+ items, how would you go

  • 0

Recently I was asked on a page with 10K+ items, how would you go about listening for click events on each item. I told him I would just bind a click to each item but looking at his face I could tell that wasn’t the answer he was looking for. I’m having a hard time findinig any online articles regarding this type of use case which is why I’m not asking this on SO. It would be helpful if you could provide some sample code with your answer to help illustrate the solution.

  • 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-01T02:51:31+00:00Added an answer on June 1, 2026 at 2:51 am

    You could use event delegation to do this…

    var handleClick = function(e) {
       // Older IEs set the `event` globally.
       e = window.event || e;
    
       // Older IEs use `srcElement` instead of the spec'd `target`.
       var target = e.target || e.srcElement;
    
       // For example's sake.
       if (target.tagName.toLowerCase() == 'a' && target.className == 'some_class') {
           // Handle this click.
       }
    
    }
    
    if (document.addEventListener) {
        document.addEventListener('click', handleClick, false);
    } else (document.attachEvent) {
        // Older IEs use `attachEvent` instead for adding event listeners.
        document.attachEvent('onclick', handleClick);
    } else {
        // When all else fails, let's take a journey back to the 90's.
        document.onclick = handleClick;
    }
    

    Event delegation works by capturing the event which bubbles up through all ancestor elements by default.

    You can (and should) replace document with the closest consistent ancestor element.

    The code example above will support all browsers that you probably care about.

    If using a library such as jQuery, the code is generally more terse…

    $(document).on('click', 'a.some_class', function() {
         // Handle this click.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked a question about using the Page.User or HttpContext.Current.User in the View.
I recently asked a question about formatting JavaScript code in Vim. And I've also
I recently asked about functional programs having no side effects, and learned what this
I was recently asked if I knew anything about Dynamic Assemblies in .Net. The
I've recently asked a question about clipping an image via path at view's drawRect
I recently asked my frontend designer to setup buttons in my account management page
Recently, I came across a web page where someone asked how to add some
I recently asked a question about storing the results of a database search in
I recently asked a question about controlling the volume of a Java audio clip
Possible Duplicate: Plain English explanation of Big O I was recently asked about my

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.