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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:37:10+00:00 2026-05-20T08:37:10+00:00

I am currently thinking about some efficiency/speed issues. I have about 40 a elements

  • 0

I am currently thinking about some efficiency/speed issues.

I have about 40 a elements and divs nested in li´s

<ul id=ul>  
<li><a href="#">Link</a><div>Text</div></li>  
<li><a href="#">Link</a><div>Text</div></li>  
<li><a href="#">Link</a><div>Text</div></li>  
<li><a href="#">Link</a><div>Text</div></li>  
<li><a href="#">Link</a><div>Text</div></li>  
....   
</ul>

On all the li´s I have hover events attached

$('#ul li').hover(function(e){
    $(this).children(div).show();},
function(){
    $(this).children(div).hide();
})

I was wondering if there was a better way than attaching 40 event handlers to the dom for a hover event. I think this can be slow in some browsers.

I heard about DOM traversing, like when you put only ONE handler on the #ul container and let dom traversing inside the browser (e.target) figure out what element has been hoverd. Anybody know how to approach this issue?

  • 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-20T08:37:10+00:00Added an answer on May 20, 2026 at 8:37 am

    .delegate() does what you describe:

    $('#ul').delegate('li', 'mouseenter', function (e) {...});
    $('#ul').delegate('li', 'mouseleave', function (e) {...});
    

    Note that .hover() is just a shortcut for the two events, mouseenter and mouseleave, hence the two calls to .degelate() above.

    Even though .delegate() is called on $('#ul'), $(this) will refer to the <li> element inside the events handlers.

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

Sidebar

Related Questions

Currently thinking about pitching the argument for us migration from vs 2005 (winforms) to
I am currently thinking about open-sourcing a project of mine and am in the
Ok, have a bunch of questions that I have been thinking about the past
currently I am thinking about data encapsulation in C# and I am a little
I have an existing application that has some parts of formatted text-blocks (standard formats
We're currentlly thinking about secureity in our applications. Our preferred method of getting data
We are currently thinking of building a cache-system to hold data pulled out of
I'm trying to make a Tetris-like game in XNA, and currently I'm thinking of
We are currently using Mysql version 5.0 in our application and are thinking of
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and

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.